Class Stage
- javafx.stage.Window
-
- javafx.stage.Stage
All Implemented Interfaces:
public class Stage extends Window
Stage class is the top level JavaFX container. The primary Stage is constructed by the platform. Additional Stage objects may be constructed by the application. Stage objects must be constructed and modified on the JavaFX Application Thread.
Many of the Stage properties are read only because they can be changed externally by the underlying platform and therefore must not be bindable.
Style
A stage has one of the following styles:
-
StageStyle.DECORATED- a stage with a solid white background and platform decorations. -
StageStyle.UNDECORATED- a stage with a solid white background and no decorations. -
StageStyle.TRANSPARENT- a stage with a transparent background and no decorations. -
StageStyle.UTILITY- a stage with a solid white background and minimal platform decorations.
The style must be initialized before the stage is made visible.
On some platforms decorations might not be available. For example, on some mobile or embedded devices. In these cases a request for a DECORATED or UTILITY window will be accepted, but no decorations will be shown.
Owner
A stage can optionally have an owner Window. When a window is a stage's owner, it is said to be the parent of that stage. When a parent window is closed, all its descendant windows are closed. The same chained behavior applied for a parent window that is iconified. A stage will always be on top of its parent window. The owner must be initialized before the stage is made visible.
Modality
A stage has one of the following modalities:
-
Modality.NONE- a stage that does not block any other window. -
Modality.WINDOW_MODAL- a stage that blocks input events from being delivered to all windows from its owner (parent) to its root. Its root is the closest ancestor window without an owner. -
Modality.APPLICATION_MODAL- a stage that blocks input events from being delivered to all windows from the same application, except for those from its child hierarchy.
When a window is blocked by a modal stage its Z-order relative to its ancestors is preserved, and it receives no input events and no window activation events, but continues to animate and render normally. Note that showing a modal stage does not necessarily block the caller. The show() method returns immediately regardless of the modality of the stage. Use the showAndWait() method if you need to block the caller until the modal stage is hidden (closed). The modality must be initialized before the stage is made visible.
Example:
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class HelloWorld extends Application {
@Override public void start(Stage stage) {
Text text = new Text(10, 40, "Hello World!");
text.setFont(new Font(40));
Scene scene = new Scene(new Group(text));
stage.setTitle("Welcome to JavaFX!");
stage.setScene(scene);
stage.sizeToScene();
stage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
} produces the following on Windows:
produces the following on Mac OSX:
produces the following on Linux:
Since:
JavaFX 2.0
-
Property Summary
All MethodsInstance MethodsConcrete Methods Type Property and Description ReadOnlyBooleanPropertyalwaysOnTopDefines whether thisStageis kept on top of other windows.ObjectProperty<String>fullScreenExitHintObjectProperty<KeyCombination>fullScreenExitKeyGet the property for the Full Screen exit key combination.ReadOnlyBooleanPropertyfullScreenSpecifies whether thisStageshould be a full-screen, undecorated window.ReadOnlyBooleanPropertyiconifiedDefines whether theStageis iconified or not.DoublePropertymaxHeightDefines the maximum height of thisStage.ReadOnlyBooleanPropertymaximizedDefines whether theStageis maximized or not.DoublePropertymaxWidthDefines the maximum width of thisStage.DoublePropertyminHeightDefines the minimum height of thisStage.DoublePropertyminWidthDefines the minimum width of thisStage.BooleanPropertyresizableDefines whether theStageis resizable or not by the user.StringPropertytitleDefines the title of theStage.
-
Constructor Summary
Constructors Constructor and Description Stage()Creates a new instance of decoratedStage.Stage(StageStyle style)Creates a new instance ofStage.
-
Method Summary
All MethodsInstance MethodsConcrete Methods Modifier and Type Method and Description ReadOnlyBooleanPropertyalwaysOnTopProperty()Defines whether thisStageis kept on top of other windows.voidclose()Closes thisStage.ObjectProperty<String>fullScreenExitHintProperty()ObjectProperty<KeyCombination>fullScreenExitKeyProperty()Get the property for the Full Screen exit key combination.ReadOnlyBooleanPropertyfullScreenProperty()Specifies whether thisStageshould be a full-screen, undecorated window.StringgetFullScreenExitHint()Gets the value of the property fullScreenExitHint.KeyCombinationgetFullScreenExitKeyCombination()Get the current sequence used to exit Full Screen mode.ObservableList<Image>getIcons()Gets the icon images to be used in the window decorations and when minimized.doublegetMaxHeight()Gets the value of the property maxHeight.doublegetMaxWidth()Gets the value of the property maxWidth.doublegetMinHeight()Gets the value of the property minHeight.doublegetMinWidth()Gets the value of the property minWidth.ModalitygetModality()Retrieves the modality attribute for this stage.WindowgetOwner()Retrieves the owner Window for this stage, or null for an unowned stage.StageStylegetStyle()Retrieves the style attribute for this stage.StringgetTitle()Gets the value of the property title.ReadOnlyBooleanPropertyiconifiedProperty()Defines whether theStageis iconified or not.voidinitModality(Modality modality)Specifies the modality for this stage.voidinitOwner(Window owner)Specifies the owner Window for this stage, or null for a top-level, unowned stage.voidinitStyle(StageStyle style)Specifies the style for this stage.booleanisAlwaysOnTop()Gets the value of the property alwaysOnTop.booleanisFullScreen()Gets the value of the property fullScreen.booleanisIconified()Gets the value of the property iconified.booleanisMaximized()Gets the value of the property maximized.booleanisResizable()Gets the value of the property resizable.DoublePropertymaxHeightProperty()Defines the maximum height of thisStage.ReadOnlyBooleanPropertymaximizedProperty()Defines whether theStageis maximized or not.DoublePropertymaxWidthProperty()Defines the maximum width of thisStage.DoublePropertyminHeightProperty()Defines the minimum height of thisStage.DoublePropertyminWidthProperty()Defines the minimum width of thisStage.BooleanPropertyresizableProperty()Defines whether theStageis resizable or not by the user.voidsetAlwaysOnTop(boolean value)Sets the value of the property alwaysOnTop.voidsetFullScreen(boolean value)Sets the value of the property fullScreen.voidsetFullScreenExitHint(String value)Specifies the text to show when a user enters full screen mode, usually used to indicate the way a user should go about exiting out of full screen mode.voidsetFullScreenExitKeyCombination(KeyCombination keyCombination)Specifies the KeyCombination that will allow the user to exit full screen mode.voidsetIconified(boolean value)Sets the value of the property iconified.voidsetMaxHeight(double value)Sets the value of the property maxHeight.voidsetMaximized(boolean value)Sets the value of the property maximized.voidsetMaxWidth(double value)Sets the value of the property maxWidth.voidsetMinHeight(double value)Sets the value of the property minHeight.voidsetMinWidth(double value)Sets the value of the property minWidth.voidsetResizable(boolean value)Sets the value of the property resizable.voidsetScene(Scene value)Specify the scene to be used on this stage.voidsetTitle(String value)Sets the value of the property title.voidshow()Attempts to show this Window by setting visibility to truevoidshowAndWait()Shows this stage and waits for it to be hidden (closed) before returning to the caller.StringPropertytitleProperty()Defines the title of theStage.voidtoBack()Send theWindowto the background.voidtoFront()Bring theWindowto the foreground.-
Methods inherited from class javafx.stage.Window
addEventFilter, addEventHandler, buildEventDispatchChain, centerOnScreen, eventDispatcherProperty, fireEvent, focusedProperty, getEventDispatcher, getHeight, getOnCloseRequest, getOnHidden, getOnHiding, getOnShowing, getOnShown, getOpacity, getProperties, getScene, getUserData, getWidth, getX, getY, hasProperties, heightProperty, hide, isFocused, isShowing, onCloseRequestProperty, onHiddenProperty, onHidingProperty, onShowingProperty, onShownProperty, opacityProperty, removeEventFilter, removeEventHandler, requestFocus, sceneProperty, setEventDispatcher, setEventHandler, setHeight, setOnCloseRequest, setOnHidden, setOnHiding, setOnShowing, setOnShown, setOpacity, setUserData, setWidth, setX, setY, showingProperty, sizeToScene, widthProperty, xProperty, yProperty
-
-
Property Detail
-
fullScreen
public final ReadOnlyBooleanProperty fullScreenProperty
Specifies whether thisStageshould be a full-screen, undecorated window.The implementation of full-screen mode is platform and profile-dependent.
When set to
true, theStagewill attempt to enter full-screen mode when visible. Set tofalseto returnStageto windowed mode. AnIllegalStateExceptionis thrown if this property is set on a thread other than the JavaFX Application Thread.The full-screen mode will be exited (and the
If the platform supports multiple screens an application can control whichfullScreenattribute will be set tofalse) if the full-screenStageloses focus or if anotherStageenters full-screen mode on the sameScreen. Note that aStagein full-screen mode can become invisible without losing its full-screen status and will again enter full-screen mode when theStagebecomes visible.Screenthe Stage will enter full-screen mode on by setting its position to be within the bounds of thatScreenprior to entering full-screen mode.However once in full-screen mode,
Stage'sx,y,width, andheightvariables will continue to represent the non-full-screen position and size of the window; the same foriconified,resizable,style, andopacity. If changes are made to any of these attributes while in full-screen mode, upon exiting full-screen mode theStagewill assume those attributes.In case that more
Stagemodes are set simultaneously their order of importance isiconified, fullScreen,maximized(from strongest to weakest).The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
Notes regarding desktop profile implementation.For desktop profile the runtime will attempt to enter full-screen exclusive mode (FSEM) if such is supported by the platform and it is allowed for this application. If either is not the case a simulated full-screen window will be used instead; the window will be maximized, made undecorated if possible, and moved to the front.
For desktop profile the user can unconditionally exit full-screen mode at any time by pressingESC.There are differences in behavior between applications if a security manager is present. Applications with permissions are allowed to enter full-screen exclusive mode unrestricted. Applications without the proper permissions will have the following restrictions:
- Applications can only enter FSEM in response to user input. More specifically, entering is allowed from mouse (
Node.mousePressed/mouseReleased/mouseClicked) or keyboard (Node.keyPressed/keyReleased/keyTyped) event handlers. It is not allowed to enter FSEM in response toESCkey. Attempting to enter FSEM from any other context will result in emulated full-screen mode.If
Stagewas constructed as full-screen but not visible it will enter full-screen mode upon becoming visible, with the same limitations to when this is allowed to happen as when settingfullScreentotrue. - If the application was allowed to enter FSEM it will have limited keyboard input. It will only receive KEY_PRESSED and KEY_RELEASED events from the following keys:
UP, DOWN, LEFT, RIGHT, SPACE, TAB, PAGE_UP, PAGE_DOWN, HOME, END, ENTER
Default value:
false
See Also:
- Applications can only enter FSEM in response to user input. More specifically, entering is allowed from mouse (
-
title
public final StringProperty titleProperty
Defines the title of theStage.Default value:
empty string
See Also:
-
iconified
public final ReadOnlyBooleanProperty iconifiedProperty
Defines whether theStageis iconified or not.In case that more
Stagemodes are set simultaneously their order of importance is iconified}fullScreen,maximized(from strongest to weakest).On some mobile and embedded platforms setting this property to true will hide the
Stagebut not show an icon for it.The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
Default value:
false
See Also:
-
maximized
public final ReadOnlyBooleanProperty maximizedProperty
Defines whether theStageis maximized or not.In case that more
Stagemodes are set simultaneously their order of importance isiconified,fullScreen, maximized (from strongest to weakest).The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
-
alwaysOnTop
public final ReadOnlyBooleanProperty alwaysOnTopProperty
Defines whether thisStageis kept on top of other windows.If some other window is already always-on-top then the relative order between these windows is unspecified (depends on platform).
There are differences in behavior between applications if a security manager is present. Applications with permissions are allowed to set "always on top" flag on a Stage. In applications without the proper permissions, an attempt to set the flag will be ignored and the property value will be restored to "false".
The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
-
resizable
public final BooleanProperty resizableProperty
Defines whether theStageis resizable or not by the user. Programatically you may still change the size of the Stage. This is a hint which allows the implementation to optionally make the Stage resizable by the user.Warning: Since 8.0 the property cannot be bound and will throw
RuntimeExceptionon an attempt to do so. This is because the setting of resizable is asynchronous on some systems or generally might be set by the system / window manager.
Bidirectional binds are still allowed, as they don't block setting of the property by the system.Default value:
true
See Also:
-
minWidth
public final DoubleProperty minWidthProperty
Defines the minimum width of thisStage.
-
minHeight
public final DoubleProperty minHeightProperty
Defines the minimum height of thisStage.
-
maxWidth
public final DoubleProperty maxWidthProperty
Defines the maximum width of thisStage.
-
maxHeight
public final DoubleProperty maxHeightProperty
Defines the maximum height of thisStage.
-
fullScreenExitKey
public final ObjectProperty<KeyCombination> fullScreenExitKeyProperty
Get the property for the Full Screen exit key combination.Since:
JavaFX 8.0
-
fullScreenExitHint
public final ObjectProperty<String> fullScreenExitHintProperty
-
-
Constructor Detail
-
Stage
public Stage()
Creates a new instance of decoratedStage.Throws:
IllegalStateException- if this constructor is called on a thread other than the JavaFX Application Thread.
-
Stage
public Stage(StageStyle style)
Creates a new instance ofStage.Parameters:
style- The style of theStageThrows:
IllegalStateException- if this constructor is called on a thread other than the JavaFX Application Thread.
-
-
Method Detail
-
setScene
public final void setScene(Scene value)
Specify the scene to be used on this stage.
-
show
public final void show()
Description copied from class:WindowAttempts to show this Window by setting visibility to true
-
showAndWait
public void showAndWait()
Shows this stage and waits for it to be hidden (closed) before returning to the caller. This method temporarily blocks processing of the current event, and starts a nested event loop to handle other events. This method must be called on the FX Application thread.A Stage is hidden (closed) by one of the following means:
- the application calls the
Window.hide()orclose()method on this stage - this stage has a non-null owner window, and its owner is closed
- the user closes the window via the window system (for example, by pressing the close button in the window decoration)
After the Stage is hidden, and the application has returned from the event handler to the event loop, the nested event loop terminates and this method returns to the caller.
For example, consider the following sequence of operations for different event handlers, assumed to execute in the order shown below:
void evtHander1(...) { stage1.showAndWait(); doSomethingAfterStage1Closed(...) } void evtHander2(...) { stage1.hide(); doSomethingElseHere(...) }evtHandler1 will block at the call to showAndWait. It will resume execution after stage1 is hidden and the current event handler, in this case evtHandler2, returns to the event loop. This means that doSomethingElseHere will execute before doSomethingAfterStage1Closed.More than one stage may be shown with showAndWait. Each call will start a new nested event loop. The stages may be hidden in any order, but a particular nested event loop (and thus the showAndWait method for the associated stage) will only terminate after all inner event loops have also terminated.
For example, consider the following sequence of operations for different event handlers, assumed to execute in the order shown below:
void evtHander1() { stage1.showAndWait(); doSomethingAfterStage1Closed(...) } void evtHander2() { stage2.showAndWait(); doSomethingAfterStage2Closed(...) } void evtHander3() { stage1.hide(); doSomethingElseHere(...) } void evtHander4() { stage2.hide(); doSomethingElseHereToo(...) }evtHandler1 will block at the call to stage1.showAndWait, starting up a nested event loop just like in the previous example. evtHandler2 will then block at the call to stage2.showAndWait, starting up another (inner) nested event loop. The first call to stage1.showAndWait will resume execution after stage1 is hidden, but only after the inner nested event loop started by stage2.showAndWait has terminated. This means that the call to stage1.showAndWait won't return until after evtHandler2 has returned. The order of execution is: stage1.showAndWait, stage2.showAndWait, stage1.hide, doSomethingElseHere, stage2.hide, doSomethingElseHereToo, doSomethingAfterStage2Closed, doSomethingAfterStage1Closed.This method must not be called on the primary stage or on a stage that is already visible.
Throws:
IllegalStateException- if this method is called on a thread other than the JavaFX Application Thread.Since:
JavaFX 2.2
- the application calls the
-
initStyle
public final void initStyle(StageStyle style)
Specifies the style for this stage. This must be done prior to making the stage visible. The style is one of: StageStyle.DECORATED, StageStyle.UNDECORATED, StageStyle.TRANSPARENT, or StageStyle.UTILITY.Default value:
StageStyle.DECORATED
Parameters:
style- the style for this stage.Throws:
IllegalStateException- if this property is set after the stage has ever been made visible.
-
getStyle
public final StageStyle getStyle()
Retrieves the style attribute for this stage.Returns:
the stage style.
-
initModality
public final void initModality(Modality modality)
Specifies the modality for this stage. This must be done prior to making the stage visible. The modality is one of: Modality.NONE, Modality.WINDOW_MODAL, or Modality.APPLICATION_MODAL.Default value:
Modality.NONE
Parameters:
modality- the modality for this stage.Throws:
IllegalStateException- if this property is set after the stage has ever been made visible.
-
getModality
public final Modality getModality()
Retrieves the modality attribute for this stage.Returns:
the modality.
-
initOwner
public final void initOwner(Window owner)
Specifies the owner Window for this stage, or null for a top-level, unowned stage. This must be done prior to making the stage visible.Default value:
null
Parameters:
owner- the owner for this stage.Throws:
IllegalStateException- if this property is set after the stage has ever been made visible.
-
getOwner
public final Window getOwner()
Retrieves the owner Window for this stage, or null for an unowned stage.Returns:
the owner Window.
-
setFullScreen
public final void setFullScreen(boolean value)
Sets the value of the property fullScreen.Property description:
Specifies whether this
Stageshould be a full-screen, undecorated window.The implementation of full-screen mode is platform and profile-dependent.
When set to
true, theStagewill attempt to enter full-screen mode when visible. Set tofalseto returnStageto windowed mode. AnIllegalStateExceptionis thrown if this property is set on a thread other than the JavaFX Application Thread.The full-screen mode will be exited (and the
If the platform supports multiple screens an application can control whichfullScreenattribute will be set tofalse) if the full-screenStageloses focus or if anotherStageenters full-screen mode on the sameScreen. Note that aStagein full-screen mode can become invisible without losing its full-screen status and will again enter full-screen mode when theStagebecomes visible.Screenthe Stage will enter full-screen mode on by setting its position to be within the bounds of thatScreenprior to entering full-screen mode.However once in full-screen mode,
Stage'sx,y,width, andheightvariables will continue to represent the non-full-screen position and size of the window; the same foriconified,resizable,style, andopacity. If changes are made to any of these attributes while in full-screen mode, upon exiting full-screen mode theStagewill assume those attributes.In case that more
Stagemodes are set simultaneously their order of importance isiconified, fullScreen,maximized(from strongest to weakest).The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
Notes regarding desktop profile implementation.For desktop profile the runtime will attempt to enter full-screen exclusive mode (FSEM) if such is supported by the platform and it is allowed for this application. If either is not the case a simulated full-screen window will be used instead; the window will be maximized, made undecorated if possible, and moved to the front.
For desktop profile the user can unconditionally exit full-screen mode at any time by pressingESC.There are differences in behavior between applications if a security manager is present. Applications with permissions are allowed to enter full-screen exclusive mode unrestricted. Applications without the proper permissions will have the following restrictions:
- Applications can only enter FSEM in response to user input. More specifically, entering is allowed from mouse (
Node.mousePressed/mouseReleased/mouseClicked) or keyboard (Node.keyPressed/keyReleased/keyTyped) event handlers. It is not allowed to enter FSEM in response toESCkey. Attempting to enter FSEM from any other context will result in emulated full-screen mode.If
Stagewas constructed as full-screen but not visible it will enter full-screen mode upon becoming visible, with the same limitations to when this is allowed to happen as when settingfullScreentotrue. - If the application was allowed to enter FSEM it will have limited keyboard input. It will only receive KEY_PRESSED and KEY_RELEASED events from the following keys:
UP, DOWN, LEFT, RIGHT, SPACE, TAB, PAGE_UP, PAGE_DOWN, HOME, END, ENTER
Default value:
false
- Applications can only enter FSEM in response to user input. More specifically, entering is allowed from mouse (
-
isFullScreen
public final boolean isFullScreen()
Gets the value of the property fullScreen.Property description:
Specifies whether this
Stageshould be a full-screen, undecorated window.The implementation of full-screen mode is platform and profile-dependent.
When set to
true, theStagewill attempt to enter full-screen mode when visible. Set tofalseto returnStageto windowed mode. AnIllegalStateExceptionis thrown if this property is set on a thread other than the JavaFX Application Thread.The full-screen mode will be exited (and the
If the platform supports multiple screens an application can control whichfullScreenattribute will be set tofalse) if the full-screenStageloses focus or if anotherStageenters full-screen mode on the sameScreen. Note that aStagein full-screen mode can become invisible without losing its full-screen status and will again enter full-screen mode when theStagebecomes visible.Screenthe Stage will enter full-screen mode on by setting its position to be within the bounds of thatScreenprior to entering full-screen mode.However once in full-screen mode,
Stage'sx,y,width, andheightvariables will continue to represent the non-full-screen position and size of the window; the same foriconified,resizable,style, andopacity. If changes are made to any of these attributes while in full-screen mode, upon exiting full-screen mode theStagewill assume those attributes.In case that more
Stagemodes are set simultaneously their order of importance isiconified, fullScreen,maximized(from strongest to weakest).The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
Notes regarding desktop profile implementation.For desktop profile the runtime will attempt to enter full-screen exclusive mode (FSEM) if such is supported by the platform and it is allowed for this application. If either is not the case a simulated full-screen window will be used instead; the window will be maximized, made undecorated if possible, and moved to the front.
For desktop profile the user can unconditionally exit full-screen mode at any time by pressingESC.There are differences in behavior between applications if a security manager is present. Applications with permissions are allowed to enter full-screen exclusive mode unrestricted. Applications without the proper permissions will have the following restrictions:
- Applications can only enter FSEM in response to user input. More specifically, entering is allowed from mouse (
Node.mousePressed/mouseReleased/mouseClicked) or keyboard (Node.keyPressed/keyReleased/keyTyped) event handlers. It is not allowed to enter FSEM in response toESCkey. Attempting to enter FSEM from any other context will result in emulated full-screen mode.If
Stagewas constructed as full-screen but not visible it will enter full-screen mode upon becoming visible, with the same limitations to when this is allowed to happen as when settingfullScreentotrue. - If the application was allowed to enter FSEM it will have limited keyboard input. It will only receive KEY_PRESSED and KEY_RELEASED events from the following keys:
UP, DOWN, LEFT, RIGHT, SPACE, TAB, PAGE_UP, PAGE_DOWN, HOME, END, ENTER
Default value:
false
- Applications can only enter FSEM in response to user input. More specifically, entering is allowed from mouse (
-
fullScreenProperty
public final ReadOnlyBooleanProperty fullScreenProperty()
Specifies whether thisStageshould be a full-screen, undecorated window.The implementation of full-screen mode is platform and profile-dependent.
When set to
true, theStagewill attempt to enter full-screen mode when visible. Set tofalseto returnStageto windowed mode. AnIllegalStateExceptionis thrown if this property is set on a thread other than the JavaFX Application Thread.The full-screen mode will be exited (and the
If the platform supports multiple screens an application can control whichfullScreenattribute will be set tofalse) if the full-screenStageloses focus or if anotherStageenters full-screen mode on the sameScreen. Note that aStagein full-screen mode can become invisible without losing its full-screen status and will again enter full-screen mode when theStagebecomes visible.Screenthe Stage will enter full-screen mode on by setting its position to be within the bounds of thatScreenprior to entering full-screen mode.However once in full-screen mode,
Stage'sx,y,width, andheightvariables will continue to represent the non-full-screen position and size of the window; the same foriconified,resizable,style, andopacity. If changes are made to any of these attributes while in full-screen mode, upon exiting full-screen mode theStagewill assume those attributes.In case that more
Stagemodes are set simultaneously their order of importance isiconified, fullScreen,maximized(from strongest to weakest).The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
Notes regarding desktop profile implementation.For desktop profile the runtime will attempt to enter full-screen exclusive mode (FSEM) if such is supported by the platform and it is allowed for this application. If either is not the case a simulated full-screen window will be used instead; the window will be maximized, made undecorated if possible, and moved to the front.
For desktop profile the user can unconditionally exit full-screen mode at any time by pressingESC.There are differences in behavior between applications if a security manager is present. Applications with permissions are allowed to enter full-screen exclusive mode unrestricted. Applications without the proper permissions will have the following restrictions:
- Applications can only enter FSEM in response to user input. More specifically, entering is allowed from mouse (
Node.mousePressed/mouseReleased/mouseClicked) or keyboard (Node.keyPressed/keyReleased/keyTyped) event handlers. It is not allowed to enter FSEM in response toESCkey. Attempting to enter FSEM from any other context will result in emulated full-screen mode.If
Stagewas constructed as full-screen but not visible it will enter full-screen mode upon becoming visible, with the same limitations to when this is allowed to happen as when settingfullScreentotrue. - If the application was allowed to enter FSEM it will have limited keyboard input. It will only receive KEY_PRESSED and KEY_RELEASED events from the following keys:
UP, DOWN, LEFT, RIGHT, SPACE, TAB, PAGE_UP, PAGE_DOWN, HOME, END, ENTER
Default value:
false
See Also:
- Applications can only enter FSEM in response to user input. More specifically, entering is allowed from mouse (
-
getIcons
public final ObservableList<Image> getIcons()
Gets the icon images to be used in the window decorations and when minimized. The images should be different sizes of the same image and the best size will be chosen, eg. 16x16, 32,32.Returns:
An observable list of icons of this window
-
setTitle
public final void setTitle(String value)
Sets the value of the property title.Property description:
Defines the title of the
Stage.Default value:
empty string
-
getTitle
public final String getTitle()
Gets the value of the property title.Property description:
Defines the title of the
Stage.Default value:
empty string
-
titleProperty
public final StringProperty titleProperty()
Defines the title of theStage.Default value:
empty string
See Also:
-
setIconified
public final void setIconified(boolean value)
Sets the value of the property iconified.Property description:
Defines whether the
Stageis iconified or not.In case that more
Stagemodes are set simultaneously their order of importance is iconified}fullScreen,maximized(from strongest to weakest).On some mobile and embedded platforms setting this property to true will hide the
Stagebut not show an icon for it.The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
Default value:
false
-
isIconified
public final boolean isIconified()
Gets the value of the property iconified.Property description:
Defines whether the
Stageis iconified or not.In case that more
Stagemodes are set simultaneously their order of importance is iconified}fullScreen,maximized(from strongest to weakest).On some mobile and embedded platforms setting this property to true will hide the
Stagebut not show an icon for it.The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
Default value:
false
-
iconifiedProperty
public final ReadOnlyBooleanProperty iconifiedProperty()
Defines whether theStageis iconified or not.In case that more
Stagemodes are set simultaneously their order of importance is iconified}fullScreen,maximized(from strongest to weakest).On some mobile and embedded platforms setting this property to true will hide the
Stagebut not show an icon for it.The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
Default value:
false
See Also:
-
setMaximized
public final void setMaximized(boolean value)
Sets the value of the property maximized.Property description:
Defines whether the
Stageis maximized or not.In case that more
Stagemodes are set simultaneously their order of importance isiconified,fullScreen, maximized (from strongest to weakest).The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
Default value:
false
Since:
JavaFX 8.0
-
isMaximized
public final boolean isMaximized()
Gets the value of the property maximized.Property description:
Defines whether the
Stageis maximized or not.In case that more
Stagemodes are set simultaneously their order of importance isiconified,fullScreen, maximized (from strongest to weakest).The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
Default value:
false
Since:
JavaFX 8.0
-
maximizedProperty
public final ReadOnlyBooleanProperty maximizedProperty()
Defines whether theStageis maximized or not.In case that more
Stagemodes are set simultaneously their order of importance isiconified,fullScreen, maximized (from strongest to weakest).The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
-
setAlwaysOnTop
public final void setAlwaysOnTop(boolean value)
Sets the value of the property alwaysOnTop.Property description:
Defines whether this
Stageis kept on top of other windows.If some other window is already always-on-top then the relative order between these windows is unspecified (depends on platform).
There are differences in behavior between applications if a security manager is present. Applications with permissions are allowed to set "always on top" flag on a Stage. In applications without the proper permissions, an attempt to set the flag will be ignored and the property value will be restored to "false".
The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
Default value:
false
Since:
JavaFX 8u20
-
isAlwaysOnTop
public final boolean isAlwaysOnTop()
Gets the value of the property alwaysOnTop.Property description:
Defines whether this
Stageis kept on top of other windows.If some other window is already always-on-top then the relative order between these windows is unspecified (depends on platform).
There are differences in behavior between applications if a security manager is present. Applications with permissions are allowed to set "always on top" flag on a Stage. In applications without the proper permissions, an attempt to set the flag will be ignored and the property value will be restored to "false".
The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
Default value:
false
Since:
JavaFX 8u20
-
alwaysOnTopProperty
public final ReadOnlyBooleanProperty alwaysOnTopProperty()
Defines whether thisStageis kept on top of other windows.If some other window is already always-on-top then the relative order between these windows is unspecified (depends on platform).
There are differences in behavior between applications if a security manager is present. Applications with permissions are allowed to set "always on top" flag on a Stage. In applications without the proper permissions, an attempt to set the flag will be ignored and the property value will be restored to "false".
The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
-
setResizable
public final void setResizable(boolean value)
Sets the value of the property resizable.Property description:
Defines whether the
Stageis resizable or not by the user. Programatically you may still change the size of the Stage. This is a hint which allows the implementation to optionally make the Stage resizable by the user.Warning: Since 8.0 the property cannot be bound and will throw
RuntimeExceptionon an attempt to do so. This is because the setting of resizable is asynchronous on some systems or generally might be set by the system / window manager.
Bidirectional binds are still allowed, as they don't block setting of the property by the system.Default value:
true
-
isResizable
public final boolean isResizable()
Gets the value of the property resizable.Property description:
Defines whether the
Stageis resizable or not by the user. Programatically you may still change the size of the Stage. This is a hint which allows the implementation to optionally make the Stage resizable by the user.Warning: Since 8.0 the property cannot be bound and will throw
RuntimeExceptionon an attempt to do so. This is because the setting of resizable is asynchronous on some systems or generally might be set by the system / window manager.
Bidirectional binds are still allowed, as they don't block setting of the property by the system.Default value:
true
-
resizableProperty
public final BooleanProperty resizableProperty()
Defines whether theStageis resizable or not by the user. Programatically you may still change the size of the Stage. This is a hint which allows the implementation to optionally make the Stage resizable by the user.Warning: Since 8.0 the property cannot be bound and will throw
RuntimeExceptionon an attempt to do so. This is because the setting of resizable is asynchronous on some systems or generally might be set by the system / window manager.
Bidirectional binds are still allowed, as they don't block setting of the property by the system.Default value:
true
See Also:
-
setMinWidth
public final void setMinWidth(double value)
Sets the value of the property minWidth.Property description:
Defines the minimum width of this
Stage.Default value:
0
Since:
JavaFX 2.1
-
getMinWidth
public final double getMinWidth()
Gets the value of the property minWidth.Property description:
Defines the minimum width of this
Stage.Default value:
0
Since:
JavaFX 2.1
-
minWidthProperty
public final DoubleProperty minWidthProperty()
Defines the minimum width of thisStage.
-
setMinHeight
public final void setMinHeight(double value)
Sets the value of the property minHeight.Property description:
Defines the minimum height of this
Stage.Default value:
0
Since:
JavaFX 2.1
-
getMinHeight
public final double getMinHeight()
Gets the value of the property minHeight.Property description:
Defines the minimum height of this
Stage.Default value:
0
Since:
JavaFX 2.1
-
minHeightProperty
public final DoubleProperty minHeightProperty()
Defines the minimum height of thisStage.
-
setMaxWidth
public final void setMaxWidth(double value)
Sets the value of the property maxWidth.Property description:
Defines the maximum width of this
Stage.Default value:
Double.MAX_VALUE
Since:
JavaFX 2.1
-
getMaxWidth
public final double getMaxWidth()
Gets the value of the property maxWidth.Property description:
Defines the maximum width of this
Stage.Default value:
Double.MAX_VALUE
Since:
JavaFX 2.1
-
maxWidthProperty
public final DoubleProperty maxWidthProperty()
Defines the maximum width of thisStage.
-
setMaxHeight
public final void setMaxHeight(double value)
Sets the value of the property maxHeight.Property description:
Defines the maximum height of this
Stage.Default value:
Double.MAX_VALUE
Since:
JavaFX 2.1
-
getMaxHeight
public final double getMaxHeight()
Gets the value of the property maxHeight.Property description:
Defines the maximum height of this
Stage.Default value:
Double.MAX_VALUE
Since:
JavaFX 2.1
-
maxHeightProperty
public final DoubleProperty maxHeightProperty()
Defines the maximum height of thisStage.
-
toFront
public void toFront()
Bring theWindowto the foreground. If theWindowis already in the foreground there is no visible difference.
-
toBack
public void toBack()
Send theWindowto the background. If theWindowis already in the background there is no visible difference. This action places thisWindowat the bottom of the stacking order on platforms that support stacking.
-
close
public void close()
Closes thisStage. This call is equivalent tohide().
-
setFullScreenExitKeyCombination
public final void setFullScreenExitKeyCombination(KeyCombination keyCombination)
Specifies the KeyCombination that will allow the user to exit full screen mode. A value of KeyCombination.NO_MATCH will not match any KeyEvent and will make it so the user is not able to escape from Full Screen mode. A value of null indicates that the default platform specific key combination should be used.An internal copy of this value is made when entering FullScreen mode and will be used to trigger the exit from the mode. If an application does not have the proper permissions, this setting will be ignored.
Parameters:
keyCombination- the key combination to exit onSince:
JavaFX 8.0
-
getFullScreenExitKeyCombination
public final KeyCombination getFullScreenExitKeyCombination()
Get the current sequence used to exit Full Screen mode.Returns:
the current setting (null for system default)
Since:
JavaFX 8.0
-
fullScreenExitKeyProperty
public final ObjectProperty<KeyCombination> fullScreenExitKeyProperty()
Get the property for the Full Screen exit key combination.Since:
JavaFX 8.0
-
setFullScreenExitHint
public final void setFullScreenExitHint(String value)
Specifies the text to show when a user enters full screen mode, usually used to indicate the way a user should go about exiting out of full screen mode. A value of null will result in the default per-locale message being displayed. If set to the empty string, then no message will be displayed.If an application does not have the proper permissions, this setting will be ignored.
Parameters:
value- the string to be displayed.Since:
JavaFX 8.0
-
getFullScreenExitHint
public final String getFullScreenExitHint()
Gets the value of the property fullScreenExitHint.
-
fullScreenExitHintProperty
public final ObjectProperty<String> fullScreenExitHintProperty()
-
© 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.