Class Screen
- javafx.stage.Screen
public final class Screen extends Object
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
All MethodsStatic MethodsInstance MethodsConcrete Methods Modifier and Type Method and Description booleanequals(Object obj)Indicates whether some other object is "equal to" this one.Rectangle2DgetBounds()Gets the bounds of thisScreen.doublegetDpi()Gets the resolution (dots per inch) of thisScreen.static ScreengetPrimary()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 ofScreensthat intersects the provided rectangle.static ObservableList<Screen>getScreensForRectangle(Rectangle2D r)Returns a ObservableList ofScreensthat intersects the provided rectangle.Rectangle2DgetVisualBounds()Gets the visual bounds of thisScreen.inthashCode()Returns a hash code for thisScreenobject.StringtoString()Returns a string representation of thisScreenobject.
-
Method Detail
-
getPrimary
public static Screen getPrimary()
The primaryScreen.
-
getScreens
public static ObservableList<Screen> getScreens()
The observable list of currently availableScreens.
-
getScreensForRectangle
public static ObservableList<Screen> getScreensForRectangle(double x, double y, double width, double height)Returns a ObservableList ofScreensthat intersects the provided rectangle.Parameters:
x- the x coordinate of the upper-left corner of the specified rectangular areaReturns:
a ObservableList of
Screensfor whichScreen.boundsintersects the provided rectangle
-
getScreensForRectangle
public static ObservableList<Screen> getScreensForRectangle(Rectangle2D r)
Returns a ObservableList ofScreensthat intersects the provided rectangle.Parameters:
r- The specifiedRectangle2DReturns:
a ObservableList of
Screensfor whichScreen.boundsintersects the provided rectangle
-
getBounds
public final Rectangle2D getBounds()
Gets the bounds of thisScreen.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 @{code Screen}
-
hashCode
public int hashCode()
Returns a hash code for thisScreenobject.
-
equals
public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one.
-
toString
public String toString()
Returns a string representation of thisScreenobject.
-
© 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.