APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javafx.stage

public Class Stage

extends Window
Class Inheritance
Imports
java.util.ArrayList, .List, com.sun.javafx.beans.property.NullCoalescingPropertyBase, com.sun.javafx.stage.ExtendedStageProperties, .HeaderButtonMetrics, .StageHelper, .StagePeerListener, javafx.application.ColorScheme, .Platform, javafx.beans.binding.ObjectBinding, javafx.beans.property.BooleanProperty, .ReadOnlyDoubleProperty, .ReadOnlyDoubleWrapper, .ReadOnlyObjectProperty, .ReadOnlyObjectWrapper, .SimpleBooleanProperty, .SimpleDoubleProperty, .StringProperty, .StringPropertyBase, .DoubleProperty, .DoublePropertyBase, .ObjectProperty, .ReadOnlyBooleanProperty, .ReadOnlyBooleanWrapper, .SimpleObjectProperty, javafx.collections.ListChangeListener.Change, .ObservableList, javafx.geometry.Dimension2D, .NodeOrientation, javafx.scene.Scene, javafx.scene.image.Image, javafx.scene.input.KeyCombination, javafx.scene.layout.HeaderBar, com.sun.javafx.application.PlatformImpl, com.sun.javafx.collections.VetoableListDecorator, .TrackableObservableList, com.sun.javafx.scene.SceneHelper, com.sun.javafx.tk.TKStage, .Toolkit, javafx.beans.NamedArg, javafx.beans.value.ObservableValue, javafx.util.Subscription

The JavaFX 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.

The JavaFX Application Thread is created as part of the startup process for the JavaFX runtime. See the javafx.application.Application class and the Platform#startup(Runnable) method for more information.

Some Stage properties are read-only, even though they have corresponding set methods, because they can be changed externally by the underlying platform, and therefore must not be bindable. Further, these properties might be ignored on some platforms, depending on whether or not there is a window manager and how it is configured. For example, a platform without a window manager might ignore the iconified property.

Style

A stage has one of the following styles:

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.

Owned Stages are tied to the parent Window. An owned stage will always be on top of its parent window. When a parent window is closed or iconified, then all owned windows will be affected as well. Owned Stages cannot be independantly iconified.

The owner must be initialized before the stage is made visible.

Modality

A stage has one of the following modalities:

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:

A visual rendering
 of a JavaFX Stage on Windows

produces the following on Mac OSX:

A visual rendering
 of a JavaFX Stage on Mac OSX

produces the following on Linux:

A visual rendering
 of a JavaFX Stage on Linux

Since
JavaFX 2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
Stage.ExtendedPropertiesImpl

This class holds attached properties for the StageStyle#EXTENDED style that are defined on HeaderBar, but associated with and stored per Stage.

private class

Field Summary

Modifier and TypeField and Description
private ReadOnlyBooleanWrapper
alwaysOnTop

Defines whether this Stage is kept on top of other windows.

private Stage.ExtendedPropertiesImpl
private ReadOnlyBooleanWrapper
fullScreen

Specifies whether this Stage should be a full-screen, undecorated window.

private final ObjectProperty<KeyCombination>
private final ObjectProperty<String>
fullScreenExitHint

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.

private ReadOnlyBooleanWrapper
iconified

Defines whether the Stage is iconified or not.

private ObservableList<Image>
icons

Defines the icon images to be used in the window decorations and when minimized.

private boolean
private boolean
private DoubleProperty
maxHeight

Defines the maximum height of this Stage.

private ReadOnlyBooleanWrapper
maximized

Defines whether the Stage is maximized or not.

private DoubleProperty
maxWidth

Defines the maximum width of this Stage.

private DoubleProperty
minHeight

Defines the minimum height of this Stage.

private DoubleProperty
minWidth

Defines the minimum width of this Stage.

private Modality
private Window
private boolean
private BooleanProperty
resizable

Defines whether the Stage is resizable or not by the user.

private static final StagePeerListener.StageAccessor
private StageStyle
private StringProperty
title

Defines the title of the Stage.

Inherited from javafx.stage.Window:
hasBeenVisible

Constructor Summary

AccessConstructor and Description
public
Stage()

Creates a new instance of decorated Stage.

public
Stage(StageStyle
The style of the Stage
style
)

Creates a new instance of Stage.

Method Summary

Modifier and TypeMethod and Description
public final ReadOnlyBooleanProperty
private ReadOnlyBooleanWrapper
public void
close()

Closes this Stage.

private void
private void
public final ObjectProperty<String>
public final ObjectProperty<KeyCombination>

Returns:

the property.
fullScreenExitKeyProperty
()

Get the property for the Full Screen exit key combination.

public final ReadOnlyBooleanProperty
private ReadOnlyBooleanWrapper
private Stage.ExtendedPropertiesImpl
public final String
public final KeyCombination

Returns:

the current setting (null for system default)
getFullScreenExitKeyCombination
()

Get the current sequence used to exit Full Screen mode.

public final ObservableList<Image>

Returns:

An observable list of icons of this window
getIcons
()

Gets the icon images to be used in the window decorations and when minimized.

public final double
public final double
public final double
public final double
public final Modality

Returns:

the modality.
getModality
()

Retrieves the modality attribute for this stage.

public final Window

Returns:

the owner Window.
getOwner
()

Retrieves the owner Window for this stage, or null for an unowned stage.

public final StageStyle

Returns:

the stage style.
getStyle
()

Retrieves the style attribute for this stage.

public final String
pack-priv Window
public final ReadOnlyBooleanProperty
private final ReadOnlyBooleanWrapper
public final void
initModality(Modality
the modality for this stage.
modality
)

Specifies the modality for this stage.

public final void
initOwner(Window
the owner for this stage.
owner
)

Specifies the owner Window for this stage, or null for a top-level, unowned stage.

public final void
initStyle(StageStyle
the style for this stage.
style
)

Specifies the style for this stage.

public final boolean
public final boolean
public final boolean
private boolean
public final boolean
pack-priv boolean
public final boolean
pack-priv boolean
isSizeToSceneAllowed()

Overrides javafx.stage.Window.isSizeToSceneAllowed.

Determines whether the sizeToScene() request is allowed or not.

public final DoubleProperty
public final ReadOnlyBooleanProperty
private final ReadOnlyBooleanWrapper
public final DoubleProperty
public final DoubleProperty
public final DoubleProperty
public final BooleanProperty
public final void
setAlwaysOnTop(boolean value)

public final void
setFullScreen(boolean value)

public final void
public final void
setFullScreenExitKeyCombination(KeyCombination
the key combination to exit on
keyCombination
)

Specifies the KeyCombination that will allow the user to exit full screen mode.

public final void
setIconified(boolean value)

pack-priv void
setImportant(boolean important)

public final void
setMaxHeight(double value)

public final void
setMaximized(boolean value)

public final void
setMaxWidth(double value)

public final void
setMinHeight(double value)

public final void
setMinWidth(double value)

pack-priv void
setPrimary(boolean primary)

public final void
setResizable(boolean value)

public final void
setScene(Scene value)

Overrides javafx.stage.Window.setScene.

Specify the scene to be used on this stage.

public final void
public final void
show()

Overrides javafx.stage.Window.show.

Attempts to show this Window by setting visibility to true

public void
showAndWait()

Shows this stage and waits for it to be hidden (closed) before returning to the caller.

public final StringProperty
public void
toBack()

Sends this Stage to the back if the stage is visible.

public void
toFront()

Brings this Stage to the front if the stage is visible.

Inherited from javafx.stage.Window:
addEventFilteraddEventHandlerapplyBoundsbuildEventDispatchChaincenterOnScreencreateInternalEventDispatcherdecreaseFocusGrabCountereventDispatcherPropertyfireEventfocusedPropertyforceIntegerRenderScalePropertygetEventDispatchergetHeightgetInternalEventDispatchergetOnCloseRequestgetOnHiddengetOnHidinggetOnShowinggetOnShowngetOpacitygetOutputScaleXgetOutputScaleYgetPeergetPeerListenergetPropertiesgetRenderScaleXgetRenderScaleYgetScenegetUserDatagetWidthgetWindowsgetXgetYhasPropertiesheightPropertyhideincreaseFocusGrabCounterisFocusedisForceIntegerRenderScaleisShowingnotifyLocationChangednotifySizeChangedonCloseRequestPropertyonHiddenPropertyonHidingPropertyonShowingPropertyonShownPropertyopacityPropertyoutputScaleXPropertyoutputScaleYPropertyremoveEventFilterremoveEventHandlerrenderScaleXPropertyrenderScaleYPropertyrequestFocusscenePropertysetEventDispatchersetEventHandlersetFocusedsetForceIntegerRenderScalesetHeightsetOnCloseRequestsetOnHiddensetOnHidingsetOnShowingsetOnShownsetOpacitysetPeersetPeerListenersetRenderScaleXsetRenderScaleYsetUserDatasetWidthsetXsetXInternalsetYsetYInternalshowingPropertysizeToSceneupdateRenderScaleswidthPropertyxPropertyyProperty