Class Screen
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 the
Screen objects are relative to the Screen.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 |
Indicates whether some other object is "equal to" this one. |
final Rectangle2D |
getBounds() |
Gets the bounds of this Screen. |
final double |
getDpi() |
Gets the resolution (dots per inch) of this Screen. |
final double |
getOutputScaleX() |
Gets the recommended output scale factor of this Screen in the horizontal (X) direction. |
final double |
getOutputScaleY() |
Gets the recommended output scale factor of this Screen in the vertical (Y) direction. |
static Screen |
getPrimary() |
The primary Screen. |
static ObservableList |
getScreens() |
The observable list of currently available Screens. |
static ObservableList |
getScreensForRectangle |
Returns a ObservableList of Screens that intersects the provided rectangle. |
static ObservableList |
getScreensForRectangle |
Returns a ObservableList of Screens that intersects the provided rectangle. |
final Rectangle2D |
getVisualBounds() |
Gets the visual bounds of this Screen. |
int |
hashCode() |
Returns a hash code for this Screen object. |
String |
toString() |
Returns a string representation of this Screen object. |
Method Details
getPrimary
public static Screen getPrimary()
The primary
Screen.- Returns:
- the primary screen
getScreens
public static ObservableList<Screen> getScreens()
The observable list of currently available
Screens.- Returns:
- observable list of currently available screens
getScreensForRectangle
public static ObservableList<Screen> getScreensForRectangle(double x, double y, double width, double height)
Returns a ObservableList of
Screens that intersects the provided rectangle.- Parameters:
-
x- the x coordinate of the upper-left corner of the specified rectangular area -
y- the y coordinate of the upper-left corner of the specified rectangular area -
width- the width of the specified rectangular area -
height- the height of the specified rectangular area - Returns:
- a ObservableList of
Screensfor whichScreen.boundsintersects the provided rectangle
getScreensForRectangle
public static ObservableList<Screen> getScreensForRectangle(Rectangle2D r)
Returns a ObservableList of
Screens that intersects the provided rectangle.- Parameters:
-
r- The specifiedRectangle2D - Returns:
- a ObservableList of
Screensfor whichScreen.boundsintersects the provided rectangle
getBounds
public final Rectangle2D getBounds()
Gets the bounds of this
Screen. The bounds will be reported adjusted for the outputScale so that resizing a Window with these bounds and the same outputScale as this Screen will cover the entire screen.- Returns:
- The bounds of this
Screen
getVisualBounds
public final Rectangle2D getVisualBounds()
Gets the visual bounds of this
Screen. These bounds account for objects in the native windowing system such as task bars and menu bars. These bounds are contained by Screen.bounds.- Returns:
- The visual bounds of this
Screen
getDpi
public final double getDpi()
Gets the resolution (dots per inch) of this
Screen.- Returns:
- The resolution of this
Screen
getOutputScaleX
public final double getOutputScaleX()
Gets the recommended output scale factor of this
Screen 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 this
Screen 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
equals
toString
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.