Top Description Inners Fields Constructors Methods
javafx.stage

public Class Window

extends Object
implements EventTarget
Class Inheritance
All Implemented Interfaces
javafx.event.EventTarget
Known Direct Subclasses
com.sun.javafx.stage.EmbeddedWindow, javafx.stage.PopupWindow, javafx.stage.Stage
Imports
java.util.HashMap, javafx.application.Platform, javafx.beans.property.DoubleProperty, .DoublePropertyBase, .ObjectProperty, .ObjectPropertyBase, .ReadOnlyBooleanProperty, .ReadOnlyBooleanWrapper, .ReadOnlyObjectProperty, .ReadOnlyObjectWrapper, .ReadOnlyDoubleProperty, .ReadOnlyDoubleWrapper, .SimpleObjectProperty, .SimpleDoubleProperty, .BooleanProperty, .SimpleBooleanProperty, javafx.collections.FXCollections, .ObservableList, .ObservableMap, javafx.event.Event, .EventDispatchChain, .EventDispatcher, .EventHandler, .EventTarget, .EventType, javafx.geometry.Rectangle2D, javafx.scene.Scene, com.sun.javafx.util.Utils, com.sun.javafx.css.StyleManager, com.sun.javafx.stage.EmbeddedWindow, .WindowEventDispatcher, .WindowHelper, .WindowPeerListener, com.sun.javafx.tk.TKPulseListener, .TKScene, .TKStage, .Toolkit, com.sun.javafx.scene.NodeHelper, .SceneHelper

A top level window within which a scene is hosted, and with which the user interacts. A Window might be a Stage, PopupWindow, or other such top level window.

Window 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 Window 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 tiling window manager might ignore the x and y properties, or treat them as hints, placing the window in a location of its choosing.

Since
JavaFX 2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private class
Window.TKBoundsConfigurator

Caches all requested bounds settings and applies them at once during the next pulse.

Field Summary

Modifier and TypeField and Description
private static final float
private static final float
private ObjectProperty<EventDispatcher>
eventDispatcher

Specifies the event dispatcher for this node.

private ReadOnlyBooleanWrapper
focused

Whether or not this Window has the keyboard or input focus.

private int
private BooleanProperty
forceIntegerRenderScale

Boolean property that controls whether only integer render scales are set by default by the system when there is a change in the associated output scale.

pack-priv boolean
private ReadOnlyDoubleWrapper
height

The height of this Window.

private boolean
private WindowEventDispatcher
private ObjectProperty<EventHandler<WindowEvent>>
onCloseRequest

Called when there is an external request to close this Window.

private ObjectProperty<EventHandler<WindowEvent>>
onHidden

Called just after the Window has been hidden.

private ObjectProperty<EventHandler<WindowEvent>>
onHiding

Called just prior to the Window being hidden.

private ObjectProperty<EventHandler<WindowEvent>>
onShowing

Called just prior to the Window being shown.

private ObjectProperty<EventHandler<WindowEvent>>
onShown

Called just after the Window is shown.

private DoubleProperty
opacity

Defines the opacity of the Window as a value between 0.0 and 1.0.

private ReadOnlyDoubleWrapper
outputScaleX

The scale that the Window will apply to horizontal scene coordinates in all stages of rendering and compositing the output to the screen or other destination device.

private ReadOnlyDoubleWrapper
outputScaleY

The scale that the Window will apply to vertical scene coordinates in all stages of rendering and compositing the output to the screen or other destination device.

private TKStage
private Window.TKBoundsConfigurator
private WindowPeerListener
private ObservableMap<Object, Object>
private DoubleProperty
renderScaleX

The horizontal scale that the Window will use when rendering its Scene to the rendering buffer.

private DoubleProperty
renderScaleY

The vertical scale that the Window will use when rendering its Scene to the rendering buffer.

private Window.SceneModel
scene

The Scene to be rendered on this Window.

private final ReadOnlyObjectWrapper<Screen>
private ReadOnlyBooleanWrapper
showing

Whether or not this Window is showing (that is, open on the user's system).

private boolean
sizeToScene

Indicates if a user requested the window to be sized to match the scene size.

private static ObservableList<Window>
private static final Object
private ReadOnlyDoubleWrapper
width

The width of this Window.

private boolean
private WindowHelper
private static ObservableList<Window>
windows

A list of all the currently _showing_ windows.

private ReadOnlyDoubleWrapper
x

The horizontal location of this Window on the screen.

private boolean
private ReadOnlyDoubleWrapper
y

The vertical location of this Window on the screen.

private boolean

Constructor Summary

AccessConstructor and Description
protected
Window()

Constructor for subclasses to call.

Method Summary

Modifier and TypeMethod and Description
public final <T extends Event> void
addEventFilter(final EventType<T>
the type of the events received by the filter
eventType
,
final EventHandler<? super T>
the event filter
eventFilter
)

Overrides default javafx.event.EventTarget.addEventFilter.

Registers an event filter for this target.

public final <T extends Event> void
addEventHandler(final EventType<T>
the type of the events received by the handler
eventType
,
final EventHandler<? super T>
the event handler
eventHandler
)

Overrides default javafx.event.EventTarget.addEventHandler.

Registers an event handler for this target.

private void
adjustSize(boolean selfSizePriority)

pack-priv final void
public EventDispatchChain
buildEventDispatchChain(EventDispatchChain
the initial chain to build from
tail
)

Implements javafx.event.EventTarget.buildEventDispatchChain.

Construct an event dispatch chain for this target.

public void
centerOnScreen()

Sets x and y properties on this Window so that it is centered on the current screen.

pack-priv WindowEventDispatcher
pack-priv void
private void
doVisibleChanged(boolean visible)

private void
doVisibleChanging(boolean visible)

public final ObjectProperty<EventDispatcher>
public final void
fireEvent(Event
the event to fire
event
)

Fires the specified event.

private void
focusChanged(final boolean newIsFocused)

public final ReadOnlyBooleanProperty
public final BooleanProperty
public final EventDispatcher
public final double
pack-priv WindowEventDispatcher
public final EventHandler<WindowEvent>
public final EventHandler<WindowEvent>
public final EventHandler<WindowEvent>
public final EventHandler<WindowEvent>
public final EventHandler<WindowEvent>
public final double
public final double
public final double
pack-priv TKStage
pack-priv WindowPeerListener
public final ObservableMap<Object, Object>

Returns:

an observable map of properties on this node for use primarily by application developers
getProperties
()

Returns an observable map of properties on this node for use primarily by application developers.

public final double
public final double
public final Scene
public Object

Returns:

The Object that was previously set, or null if no property has been set or if null was set.
getUserData
()

Returns a previously set Object property, or null if no such property has been set using the Window#setUserData(java.lang.Object) method.

public final double
pack-priv Window
public static ObservableList<Window>

Returns:

A list containing all windows that are currently showing.
getWindows
()

Returns a list containing a reference to the currently showing JavaFX windows.

private Screen
public final double
getX()

public final double
getY()

public boolean

Returns:

true if node has properties.
hasProperties
()

Tests if Window has properties.

public final ReadOnlyDoubleProperty
public void
hide()

Attempts to hide this Window by setting the visibility to false.

pack-priv void
private void
public final boolean
public final boolean
public final boolean
pack-priv boolean

Returns:

true if allowed, false otherwise
isSizeToSceneAllowed
()

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

pack-priv void
notifyLocationChanged(double
the new window x position
newX
,
double
the new window y position
newY
)

Notification from the windowing system that the window's position has changed.

private void
pack-priv void
notifySizeChanged(double
the new window width
newWidth
,
double
the new window height
newHeight
)

Notification from the windowing system that the window's size has changed.

public final ObjectProperty<EventHandler<WindowEvent>>
public final ObjectProperty<EventHandler<WindowEvent>>
public final ObjectProperty<EventHandler<WindowEvent>>
public final ObjectProperty<EventHandler<WindowEvent>>
public final ObjectProperty<EventHandler<WindowEvent>>
public final DoubleProperty
public final ReadOnlyDoubleProperty
public final ReadOnlyDoubleProperty
public final <T extends Event> void
removeEventFilter(final EventType<T>
the event type from which to unregister
eventType
,
final EventHandler<? super T>
the event filter
eventFilter
)

Overrides default javafx.event.EventTarget.removeEventFilter.

Unregisters a previously registered event filter from this target.

public final <T extends Event> void
removeEventHandler(final EventType<T>
the event type from which to unregister
eventType
,
final EventHandler<? super T>
the event handler
eventHandler
)

Overrides default javafx.event.EventTarget.removeEventHandler.

Unregisters a previously registered event handler from this target.

public final DoubleProperty
public final DoubleProperty
public final void
requestFocus()

Requests that this Window get the input focus.

public final ReadOnlyObjectProperty<Scene>
private ReadOnlyObjectProperty<Screen>
public final void
protected final <
the specific event class of the handler
T extends Event
>
void
setEventHandler(final EventType<T>
the event type to associate with the given eventHandler
eventType
,
final EventHandler<? super T>
the handler to register, or null to unregister
eventHandler
)

Sets the handler to use for this event type.

pack-priv final void
setFocused(boolean value)

public final void
public final void
setHeight(double value)

public final void
public final void
public final void
public final void
public final void
public final void
setOpacity(double value)

pack-priv void
pack-priv void
public final void
setRenderScaleX(double scale)

public final void
setRenderScaleY(double scale)

protected void
setScene(Scene
the value for the scene property
value
)

Sets the value of the scene property.

private void
setShowing(boolean value)

public void
setUserData(Object
The value to be stored - this can later be retrieved by calling Window#getUserData().
value
)

Convenience method for setting a single Object property that can be retrieved at a later date.

public final void
setWidth(double value)

public final void
setX(double value)

pack-priv void
setXInternal(double value)

public final void
setY(double value)

pack-priv void
setYInternal(double value)

protected void
show()

Attempts to show this Window by setting visibility to true

public final ReadOnlyBooleanProperty
public void
sizeToScene()

Set the width and height of this Window to match the size of the content of this Window's Scene.

private void
updateOutputScales(double sx, double sy)

pack-priv void
updateRenderScales(double sx, double sy)

public final ReadOnlyDoubleProperty
public final ReadOnlyDoubleProperty
public final ReadOnlyDoubleProperty
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait