- java.lang.Object
-
- javafx.stage.Screen
-
public final class Screen extends Object
Describes the characteristics of a graphics destination such as monitor. In a virtual device multi-screen environment in which the desktop area could span multiple physical screen devices, the bounds of theScreen
objects are relative to theScreen.primary
.For example:
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds(); //set Stage boundaries to visible bounds of the main screen stage.setX(primaryScreenBounds.getMinX()); stage.setY(primaryScreenBounds.getMinY()); stage.setWidth(primaryScreenBounds.getWidth()); stage.setHeight(primaryScreenBounds.getHeight()); stage.show();
- Since:
- JavaFX 2.0
-
-
Method Summary
Modifier and Type Method Description boolean
equals(Object obj)
Indicates whether some other object is "equal to" this one.Rectangle2D
getBounds()
Gets the bounds of thisScreen
.double
getDpi()
Gets the resolution (dots per inch) of thisScreen
.double
getOutputScaleX()
Gets the recommended output scale factor of thisScreen
in the horizontal (X
) direction.double
getOutputScaleY()
Gets the recommended output scale factor of thisScreen
in the vertical (Y
) direction.static Screen
getPrimary()
The primaryScreen
.static ObservableList<Screen>
getScreens()
The observable list of currently availableScreens
.static ObservableList<Screen>
getScreensForRectangle(double x, double y, double width, double height)
Returns a ObservableList ofScreens
that intersects the provided rectangle.static ObservableList<Screen>
getScreensForRectangle(Rectangle2D r)
Returns a ObservableList ofScreens
that intersects the provided rectangle.Rectangle2D
getVisualBounds()
Gets the visual bounds of thisScreen
.int
hashCode()
Returns a hash code for thisScreen
object.String
toString()
Returns a string representation of thisScreen
object.
-
-
-
Method Detail
-
getPrimary
public static Screen getPrimary()
The primaryScreen
.- Returns:
- the primary screen
-
getScreens
public static ObservableList<Screen> getScreens()
The observable list of currently availableScreens
.- Returns:
- observable list of currently available screens
-
getScreensForRectangle
public static ObservableList<Screen> getScreensForRectangle(double x, double y, double width, double height)
Returns a ObservableList ofScreens
that intersects the provided rectangle.- Parameters:
x
- the x coordinate of the upper-left corner of the specified rectangular areay
- the y coordinate of the upper-left corner of the specified rectangular areawidth
- the width of the specified rectangular areaheight
- the height of the specified rectangular area- Returns:
- a ObservableList of
Screens
for whichScreen.bounds
intersects the provided rectangle
-
getScreensForRectangle
public static ObservableList<Screen> getScreensForRectangle(Rectangle2D r)
Returns a ObservableList ofScreens
that intersects the provided rectangle.- Parameters:
r
- The specifiedRectangle2D
- Returns:
- a ObservableList of
Screens
for whichScreen.bounds
intersects the provided rectangle
-
getBounds
public final Rectangle2D getBounds()
Gets the bounds of thisScreen
. The bounds will be reported adjusted for theoutputScale
so that resizing aWindow
with these bounds and the sameoutputScale
as thisScreen
will cover the entire screen.- Returns:
- The bounds of this
Screen
-
getVisualBounds
public final Rectangle2D getVisualBounds()
Gets the visual bounds of thisScreen
. These bounds account for objects in the native windowing system such as task bars and menu bars. These bounds are contained byScreen.bounds
.- Returns:
- The visual bounds of this
Screen
-
getDpi
public final double getDpi()
Gets the resolution (dots per inch) of thisScreen
.- Returns:
- The resolution of this
Screen
-
getOutputScaleX
public final double getOutputScaleX()
Gets the recommended output scale factor of thisScreen
in the horizontal (X
) direction. This scale factor should be applied to a scene in order to compensate for the resolution and viewing distance of the output device. The visual bounds will be reported relative to this scale factor.- Returns:
- the recommended output scale factor for the screen.
- Since:
- 9
-
getOutputScaleY
public final double getOutputScaleY()
Gets the recommended output scale factor of thisScreen
in the vertical (Y
) direction. This scale factor will be applied to the scene in order to compensate for the resolution and viewing distance of the output device. The visual bounds will be reported relative to this scale factor.- Returns:
- the recommended output scale factor for the screen.
- Since:
- 9
-
hashCode
public int hashCode()
Returns a hash code for thisScreen
object.
-
equals
public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one.
-
-