Class Window
- All Implemented Interfaces:
EventTarget
- Direct Known Subclasses:
PopupWindow,Stage
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 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
-
Property Summary
PropertiesTypePropertyDescriptionfinal ObjectProperty<EventDispatcher> Specifies the event dispatcher for this node.final ReadOnlyBooleanPropertyWhether or not thisWindowhas the keyboard or input focus.final BooleanPropertyBoolean 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.final ReadOnlyDoublePropertyThe height of thisWindow.final ObjectProperty<EventHandler<WindowEvent>> Called when there is an external request to close thisWindow.final ObjectProperty<EventHandler<WindowEvent>> Called just after the Window has been hidden.final ObjectProperty<EventHandler<WindowEvent>> Called just prior to the Window being hidden.final ObjectProperty<EventHandler<WindowEvent>> Called just prior to the Window being shown.final ObjectProperty<EventHandler<WindowEvent>> Called just after the Window is shown.final DoublePropertyDefines the opacity of theWindowas a value between 0.0 and 1.0.final ReadOnlyDoublePropertyThe scale that theWindowwill apply to horizontal scene coordinates in all stages of rendering and compositing the output to the screen or other destination device.final ReadOnlyDoublePropertyThe scale that theWindowwill apply to vertical scene coordinates in all stages of rendering and compositing the output to the screen or other destination device.final DoublePropertyThe horizontal scale that theWindowwill use when rendering itsSceneto the rendering buffer.final DoublePropertyThe vertical scale that theWindowwill use when rendering itsSceneto the rendering buffer.final ReadOnlyObjectProperty<Scene> TheSceneto be rendered on thisWindow.final ReadOnlyBooleanPropertyWhether or not thisWindowis showing (that is, open on the user's system).final ReadOnlyDoublePropertyThe width of thisWindow.final ReadOnlyDoublePropertyThe horizontal location of thisWindowon the screen.final ReadOnlyDoublePropertyThe vertical location of thisWindowon the screen. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal <T extends Event>
voidaddEventFilter(EventType<T> eventType, EventHandler<? super T> eventFilter) Registers an event filter for this target.final <T extends Event>
voidaddEventHandler(EventType<T> eventType, EventHandler<? super T> eventHandler) Registers an event handler for this target.Construct an event dispatch chain for this target.voidSets x and y properties on this Window so that it is centered on the current screen.final ObjectProperty<EventDispatcher> Specifies the event dispatcher for this node.final voidFires the specified event.final ReadOnlyBooleanPropertyWhether or not thisWindowhas the keyboard or input focus.final BooleanPropertyBoolean 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.final EventDispatcherGets the value of theeventDispatcherproperty.final doubleGets the value of theheightproperty.final EventHandler<WindowEvent> Gets the value of theonCloseRequestproperty.final EventHandler<WindowEvent> Gets the value of theonHiddenproperty.final EventHandler<WindowEvent> Gets the value of theonHidingproperty.final EventHandler<WindowEvent> Gets the value of theonShowingproperty.final EventHandler<WindowEvent> Gets the value of theonShownproperty.final doubleGets the value of theopacityproperty.final doubleGets the value of theoutputScaleXproperty.final doubleGets the value of theoutputScaleYproperty.final ObservableMap<Object, Object> Returns an observable map of properties on this node for use primarily by application developers.final doubleGets the value of therenderScaleXproperty.final doubleGets the value of therenderScaleYproperty.final ScenegetScene()Gets the value of thesceneproperty.Returns a previously set Object property, or null if no such property has been set using thesetUserData(java.lang.Object)method.final doublegetWidth()Gets the value of thewidthproperty.static ObservableList<Window> Returns a list containing a reference to the currently showing JavaFX windows.final doublegetX()Gets the value of thexproperty.final doublegetY()Gets the value of theyproperty.booleanTests if Window has properties.final ReadOnlyDoublePropertyThe height of thisWindow.voidhide()Attempts to hide this Window by setting the visibility to false.final booleanGets the value of thefocusedproperty.final booleanGets the value of theforceIntegerRenderScaleproperty.final booleanGets the value of theshowingproperty.final ObjectProperty<EventHandler<WindowEvent>> Called when there is an external request to close thisWindow.final ObjectProperty<EventHandler<WindowEvent>> Called just after the Window has been hidden.final ObjectProperty<EventHandler<WindowEvent>> Called just prior to the Window being hidden.final ObjectProperty<EventHandler<WindowEvent>> Called just prior to the Window being shown.final ObjectProperty<EventHandler<WindowEvent>> Called just after the Window is shown.final DoublePropertyDefines the opacity of theWindowas a value between 0.0 and 1.0.final ReadOnlyDoublePropertyThe scale that theWindowwill apply to horizontal scene coordinates in all stages of rendering and compositing the output to the screen or other destination device.final ReadOnlyDoublePropertyThe scale that theWindowwill apply to vertical scene coordinates in all stages of rendering and compositing the output to the screen or other destination device.final <T extends Event>
voidremoveEventFilter(EventType<T> eventType, EventHandler<? super T> eventFilter) Unregisters a previously registered event filter from this target.final <T extends Event>
voidremoveEventHandler(EventType<T> eventType, EventHandler<? super T> eventHandler) Unregisters a previously registered event handler from this target.final DoublePropertyThe horizontal scale that theWindowwill use when rendering itsSceneto the rendering buffer.final DoublePropertyThe vertical scale that theWindowwill use when rendering itsSceneto the rendering buffer.final voidRequests that thisWindowget the input focus.final ReadOnlyObjectProperty<Scene> TheSceneto be rendered on thisWindow.final voidSets the value of theeventDispatcherproperty.protected final <T extends Event>
voidsetEventHandler(EventType<T> eventType, EventHandler<? super T> eventHandler) Sets the handler to use for this event type.final voidsetForceIntegerRenderScale(boolean forced) Sets the value of theforceIntegerRenderScaleproperty.final voidsetHeight(double value) Sets the value of theheightproperty.final voidsetOnCloseRequest(EventHandler<WindowEvent> value) Sets the value of theonCloseRequestproperty.final voidsetOnHidden(EventHandler<WindowEvent> value) Sets the value of theonHiddenproperty.final voidsetOnHiding(EventHandler<WindowEvent> value) Sets the value of theonHidingproperty.final voidsetOnShowing(EventHandler<WindowEvent> value) Sets the value of theonShowingproperty.final voidsetOnShown(EventHandler<WindowEvent> value) Sets the value of theonShownproperty.final voidsetOpacity(double value) Sets the value of theopacityproperty.final voidsetRenderScaleX(double scale) Sets the value of therenderScaleXproperty.final voidsetRenderScaleY(double scale) Sets the value of therenderScaleYproperty.protected voidSets the value of thesceneproperty.voidsetUserData(Object value) Convenience method for setting a single Object property that can be retrieved at a later date.final voidsetWidth(double value) Sets the value of thewidthproperty.final voidsetX(double value) Sets the value of thexproperty.final voidsetY(double value) Sets the value of theyproperty.protected voidshow()Attempts to show this Window by setting visibility to truefinal ReadOnlyBooleanPropertyWhether or not thisWindowis showing (that is, open on the user's system).voidSet the width and height of this Window to match the size of the content of this Window's Scene.final ReadOnlyDoublePropertyThe width of thisWindow.final ReadOnlyDoublePropertyThe horizontal location of thisWindowon the screen.final ReadOnlyDoublePropertyThe vertical location of thisWindowon the screen.
-
Property Details
-
outputScaleX
The scale that theWindowwill apply to horizontal scene coordinates in all stages of rendering and compositing the output to the screen or other destination device. This property is updated asynchronously by the system at various times including:- Window creation
- At some point during moving a window to a new
Screenwhich may be before or after theScreenproperty is updated. - In response to a change in user preferences for output scaling.
- Since:
- 9
- See Also:
-
outputScaleY
The scale that theWindowwill apply to vertical scene coordinates in all stages of rendering and compositing the output to the screen or other destination device. This property is updated asynchronously by the system at various times including:- Window creation
- At some point during moving a window to a new
Screenwhich may be before or after theScreenproperty is updated. - In response to a change in user preferences for output scaling.
- Since:
- 9
- See Also:
-
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. TherenderScaleproperties will be updated directly and simultaneously with any changes in the associatedoutputScaleproperties, but the values can be overridden by subsequent calls to thesetRenderScalesetters or through appropriate use of binding. This property will not prevent setting non-integer scales directly using therenderScaleproperty object or the convenience setter method.- Default value:
- false
- Since:
- 9
- See Also:
-
renderScaleX
The horizontal scale that theWindowwill use when rendering itsSceneto the rendering buffer. This property is automatically updated whenever there is a change in theoutputScaleXproperty and can be overridden either by callingsetRenderScaleX()in response to a listener on theoutputScaleXproperty or by binding it appropriately.- Default value:
- outputScaleX
- Since:
- 9
- See Also:
-
renderScaleY
The vertical scale that theWindowwill use when rendering itsSceneto the rendering buffer. This property is automatically updated whenever there is a change in theoutputScaleYproperty and can be overridden either by callingsetRenderScaleY()in response to a listener on theoutputScaleYproperty or by binding it appropriately.- Default value:
- outputScaleY
- Since:
- 9
- See Also:
-
x
The horizontal location of thisWindowon the screen. Changing this attribute will move theWindowhorizontally. If thisWindowis an instance ofStage, changing this attribute will not visually affect theWindowwhilefullScreenis true, but will be honored by theWindowoncefullScreenbecomes false.This property is read-only because it can be changed externally by the underlying platform. Further, setting this property might be ignored on some platforms.
- See Also:
-
y
The vertical location of thisWindowon the screen. Changing this attribute will move theWindowvertically. If thisWindowis an instance ofStage, changing this attribute will not visually affect theWindowwhilefullScreenis true, but will be honored by theWindowoncefullScreenbecomes false.This property is read-only because it can be changed externally by the underlying platform. Further, setting this property might be ignored on some platforms.
- See Also:
-
width
The width of thisWindow. Changing this attribute will narrow or widen the width of theWindow. This value includes any and all decorations which may be added by the Operating System such as resizable frame handles. Typical applications will set theScenewidth instead. ThisWindowwill take its width from the scene if it has never been set by the application. Resizing the window by end user does not count as a setting the width by the application. If thisWindowis an instance ofStage, changing this attribute will not visually affect theWindowwhilefullScreenis true, but will be honored by theWindowoncefullScreenbecomes false.This property is read-only because it can be changed externally by the underlying platform. Further, setting this property might be ignored on some platforms.
- See Also:
-
height
The height of thisWindow. Changing this attribute will shrink or heighten the height of theWindow. This value includes any and all decorations which may be added by the Operating System such as the title bar. Typical applications will set theSceneheight instead. This window will take its height from the scene if it has never been set by the application. Resizing this window by end user does not count as a setting the height by the application. If thisWindowis an instance ofStage, changing this attribute will not visually affect theWindowwhilefullScreenis true, but will be honored by theWindowoncefullScreenbecomes false.This property is read-only because it can be changed externally by the underlying platform. Further, setting this property might be ignored on some platforms.
- See Also:
-
focused
Whether or not thisWindowhas the keyboard or input focus.- See Also:
-
scene
TheSceneto be rendered on thisWindow. There can only be oneSceneon theWindowat a time, and aScenecan only be on oneWindowat a time. Setting aSceneon a differentWindowwill cause the oldWindowto lose the reference before the new one gains it. You may swapScenes on aWindowat any time, even if it is an instance ofStageand withfullScreenset totrue.If the width or height of this
Windowhave never been set by the application, setting the scene will cause thisWindowto take its width or height from that scene. Resizing thisWindowby end user does not count as setting the width or height by the application.An
IllegalStateExceptionis thrown if this property is set on a thread other than the JavaFX Application Thread.- Default value:
null- See Also:
-
opacity
Defines the opacity of theWindowas a value between 0.0 and 1.0. The opacity is reflected across theWindow, itsDecorationand itsScenecontent. On a JavaFX runtime platform that does not support opacity, assigning a value to this variable will have no visible difference. AWindowwith 0% opacity is fully translucent. Typically, aWindowwith 0% opacity will not receive any mouse events.- Default value:
- 1.0
- See Also:
-
onCloseRequest
Called when there is an external request to close thisWindow. The installed event handler can prevent window closing by consuming the received event.- See Also:
-
onShowing
Called just prior to the Window being shown.- See Also:
-
onShown
Called just after the Window is shown.- See Also:
-
onHiding
Called just prior to the Window being hidden.- See Also:
-
onHidden
Called just after the Window has been hidden. When theWindowis hidden, this event handler is invoked allowing the developer to clean up resources or perform other tasks when theWindowis closed.- See Also:
-
showing
Whether or not thisWindowis showing (that is, open on the user's system). The Window might be "showing", yet the user might not be able to see it due to the Window being rendered behind another Window or due to the Window being positioned off the monitor.- Default value:
- false
- See Also:
-
eventDispatcher
Specifies the event dispatcher for this node. The default event dispatcher sends the received events to the registered event handlers and filters. When replacing the value with a newEventDispatcher, the new dispatcher should forward events to the replaced dispatcher to maintain the node's default event handling behavior.- See Also:
-
-
Constructor Details
-
Window
protected Window()Constructor for subclasses to call.
-
-
Method Details
-
getWindows
Returns a list containing a reference to the currently showing JavaFX windows. The list is unmodifiable - attempting to modify this list will result in anUnsupportedOperationExceptionbeing thrown at runtime.- Returns:
- A list containing all windows that are currently showing.
- Since:
- 9
-
sizeToScene
public void sizeToScene()Set the width and height of this Window to match the size of the content of this Window's Scene.This request might be ignored if the Window is not allowed to do so, for example a
Stagemay bemaximizedor infullScreenand therefore does not allow this request. If that is the case, this request is remembered and reapplied later when allowed. -
centerOnScreen
public void centerOnScreen()Sets x and y properties on this Window so that it is centered on the current screen. The current screen is determined from the intersection of current window bounds and visual bounds of all screens. -
getOutputScaleX
public final double getOutputScaleX()Gets the value of theoutputScaleXproperty.- Property description:
- The scale that the
Windowwill apply to horizontal scene coordinates in all stages of rendering and compositing the output to the screen or other destination device. This property is updated asynchronously by the system at various times including:- Window creation
- At some point during moving a window to a new
Screenwhich may be before or after theScreenproperty is updated. - In response to a change in user preferences for output scaling.
- Returns:
- the value of the
outputScaleXproperty - Since:
- 9
- See Also:
-
outputScaleXProperty
The scale that theWindowwill apply to horizontal scene coordinates in all stages of rendering and compositing the output to the screen or other destination device. This property is updated asynchronously by the system at various times including:- Window creation
- At some point during moving a window to a new
Screenwhich may be before or after theScreenproperty is updated. - In response to a change in user preferences for output scaling.
- Returns:
- the
outputScaleXproperty - Since:
- 9
- See Also:
-
getOutputScaleY
public final double getOutputScaleY()Gets the value of theoutputScaleYproperty.- Property description:
- The scale that the
Windowwill apply to vertical scene coordinates in all stages of rendering and compositing the output to the screen or other destination device. This property is updated asynchronously by the system at various times including:- Window creation
- At some point during moving a window to a new
Screenwhich may be before or after theScreenproperty is updated. - In response to a change in user preferences for output scaling.
- Returns:
- the value of the
outputScaleYproperty - Since:
- 9
- See Also:
-
outputScaleYProperty
The scale that theWindowwill apply to vertical scene coordinates in all stages of rendering and compositing the output to the screen or other destination device. This property is updated asynchronously by the system at various times including:- Window creation
- At some point during moving a window to a new
Screenwhich may be before or after theScreenproperty is updated. - In response to a change in user preferences for output scaling.
- Returns:
- the
outputScaleYproperty - Since:
- 9
- See Also:
-
setForceIntegerRenderScale
public final void setForceIntegerRenderScale(boolean forced) Sets the value of theforceIntegerRenderScaleproperty.- Property description:
- 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.
The
renderScaleproperties will be updated directly and simultaneously with any changes in the associatedoutputScaleproperties, but the values can be overridden by subsequent calls to thesetRenderScalesetters or through appropriate use of binding. This property will not prevent setting non-integer scales directly using therenderScaleproperty object or the convenience setter method. - Default value:
- false
- Parameters:
forced- the value for theforceIntegerRenderScaleproperty- Since:
- 9
- See Also:
-
isForceIntegerRenderScale
public final boolean isForceIntegerRenderScale()Gets the value of theforceIntegerRenderScaleproperty.- Property description:
- 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.
The
renderScaleproperties will be updated directly and simultaneously with any changes in the associatedoutputScaleproperties, but the values can be overridden by subsequent calls to thesetRenderScalesetters or through appropriate use of binding. This property will not prevent setting non-integer scales directly using therenderScaleproperty object or the convenience setter method. - Default value:
- false
- Returns:
- the value of the
forceIntegerRenderScaleproperty - Since:
- 9
- See Also:
-
forceIntegerRenderScaleProperty
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. TherenderScaleproperties will be updated directly and simultaneously with any changes in the associatedoutputScaleproperties, but the values can be overridden by subsequent calls to thesetRenderScalesetters or through appropriate use of binding. This property will not prevent setting non-integer scales directly using therenderScaleproperty object or the convenience setter method.- Default value:
- false
- Returns:
- the
forceIntegerRenderScaleproperty - Since:
- 9
- See Also:
-
setRenderScaleX
public final void setRenderScaleX(double scale) Sets the value of therenderScaleXproperty.- Property description:
- The horizontal scale that the
Windowwill use when rendering itsSceneto the rendering buffer. This property is automatically updated whenever there is a change in theoutputScaleXproperty and can be overridden either by callingsetRenderScaleX()in response to a listener on theoutputScaleXproperty or by binding it appropriately. - Default value:
- outputScaleX
- Parameters:
scale- the value for therenderScaleXproperty- Since:
- 9
- See Also:
-
getRenderScaleX
public final double getRenderScaleX()Gets the value of therenderScaleXproperty.- Property description:
- The horizontal scale that the
Windowwill use when rendering itsSceneto the rendering buffer. This property is automatically updated whenever there is a change in theoutputScaleXproperty and can be overridden either by callingsetRenderScaleX()in response to a listener on theoutputScaleXproperty or by binding it appropriately. - Default value:
- outputScaleX
- Returns:
- the value of the
renderScaleXproperty - Since:
- 9
- See Also:
-
renderScaleXProperty
The horizontal scale that theWindowwill use when rendering itsSceneto the rendering buffer. This property is automatically updated whenever there is a change in theoutputScaleXproperty and can be overridden either by callingsetRenderScaleX()in response to a listener on theoutputScaleXproperty or by binding it appropriately.- Default value:
- outputScaleX
- Returns:
- the
renderScaleXproperty - Since:
- 9
- See Also:
-
setRenderScaleY
public final void setRenderScaleY(double scale) Sets the value of therenderScaleYproperty.- Property description:
- The vertical scale that the
Windowwill use when rendering itsSceneto the rendering buffer. This property is automatically updated whenever there is a change in theoutputScaleYproperty and can be overridden either by callingsetRenderScaleY()in response to a listener on theoutputScaleYproperty or by binding it appropriately. - Default value:
- outputScaleY
- Parameters:
scale- the value for therenderScaleYproperty- Since:
- 9
- See Also:
-
getRenderScaleY
public final double getRenderScaleY()Gets the value of therenderScaleYproperty.- Property description:
- The vertical scale that the
Windowwill use when rendering itsSceneto the rendering buffer. This property is automatically updated whenever there is a change in theoutputScaleYproperty and can be overridden either by callingsetRenderScaleY()in response to a listener on theoutputScaleYproperty or by binding it appropriately. - Default value:
- outputScaleY
- Returns:
- the value of the
renderScaleYproperty - Since:
- 9
- See Also:
-
renderScaleYProperty
The vertical scale that theWindowwill use when rendering itsSceneto the rendering buffer. This property is automatically updated whenever there is a change in theoutputScaleYproperty and can be overridden either by callingsetRenderScaleY()in response to a listener on theoutputScaleYproperty or by binding it appropriately.- Default value:
- outputScaleY
- Returns:
- the
renderScaleYproperty - Since:
- 9
- See Also:
-
setX
public final void setX(double value) Sets the value of thexproperty.- Property description:
- The horizontal location of this
Windowon the screen. Changing this attribute will move theWindowhorizontally. If thisWindowis an instance ofStage, changing this attribute will not visually affect theWindowwhilefullScreenis true, but will be honored by theWindowoncefullScreenbecomes false.This property is read-only because it can be changed externally by the underlying platform. Further, setting this property might be ignored on some platforms.
- Parameters:
value- the value for thexproperty- See Also:
-
getX
public final double getX()Gets the value of thexproperty.- Property description:
- The horizontal location of this
Windowon the screen. Changing this attribute will move theWindowhorizontally. If thisWindowis an instance ofStage, changing this attribute will not visually affect theWindowwhilefullScreenis true, but will be honored by theWindowoncefullScreenbecomes false.This property is read-only because it can be changed externally by the underlying platform. Further, setting this property might be ignored on some platforms.
- Returns:
- the value of the
xproperty - See Also:
-
xProperty
The horizontal location of thisWindowon the screen. Changing this attribute will move theWindowhorizontally. If thisWindowis an instance ofStage, changing this attribute will not visually affect theWindowwhilefullScreenis true, but will be honored by theWindowoncefullScreenbecomes false.This property is read-only because it can be changed externally by the underlying platform. Further, setting this property might be ignored on some platforms.
- Returns:
- the
xproperty - See Also:
-
setY
public final void setY(double value) Sets the value of theyproperty.- Property description:
- The vertical location of this
Windowon the screen. Changing this attribute will move theWindowvertically. If thisWindowis an instance ofStage, changing this attribute will not visually affect theWindowwhilefullScreenis true, but will be honored by theWindowoncefullScreenbecomes false.This property is read-only because it can be changed externally by the underlying platform. Further, setting this property might be ignored on some platforms.
- Parameters:
value- the value for theyproperty- See Also:
-
getY
public final double getY()Gets the value of theyproperty.- Property description:
- The vertical location of this
Windowon the screen. Changing this attribute will move theWindowvertically. If thisWindowis an instance ofStage, changing this attribute will not visually affect theWindowwhilefullScreenis true, but will be honored by theWindowoncefullScreenbecomes false.This property is read-only because it can be changed externally by the underlying platform. Further, setting this property might be ignored on some platforms.
- Returns:
- the value of the
yproperty - See Also:
-
yProperty
The vertical location of thisWindowon the screen. Changing this attribute will move theWindowvertically. If thisWindowis an instance ofStage, changing this attribute will not visually affect theWindowwhilefullScreenis true, but will be honored by theWindowoncefullScreenbecomes false.This property is read-only because it can be changed externally by the underlying platform. Further, setting this property might be ignored on some platforms.
- Returns:
- the
yproperty - See Also:
-
setWidth
public final void setWidth(double value) Sets the value of thewidthproperty.- Property description:
- The width of this
Window. Changing this attribute will narrow or widen the width of theWindow. This value includes any and all decorations which may be added by the Operating System such as resizable frame handles. Typical applications will set theScenewidth instead. ThisWindowwill take its width from the scene if it has never been set by the application. Resizing the window by end user does not count as a setting the width by the application. If thisWindowis an instance ofStage, changing this attribute will not visually affect theWindowwhilefullScreenis true, but will be honored by theWindowoncefullScreenbecomes false.This property is read-only because it can be changed externally by the underlying platform. Further, setting this property might be ignored on some platforms.
- Parameters:
value- the value for thewidthproperty- See Also:
-
getWidth
public final double getWidth()Gets the value of thewidthproperty.- Property description:
- The width of this
Window. Changing this attribute will narrow or widen the width of theWindow. This value includes any and all decorations which may be added by the Operating System such as resizable frame handles. Typical applications will set theScenewidth instead. ThisWindowwill take its width from the scene if it has never been set by the application. Resizing the window by end user does not count as a setting the width by the application. If thisWindowis an instance ofStage, changing this attribute will not visually affect theWindowwhilefullScreenis true, but will be honored by theWindowoncefullScreenbecomes false.This property is read-only because it can be changed externally by the underlying platform. Further, setting this property might be ignored on some platforms.
- Returns:
- the value of the
widthproperty - See Also:
-
widthProperty
The width of thisWindow. Changing this attribute will narrow or widen the width of theWindow. This value includes any and all decorations which may be added by the Operating System such as resizable frame handles. Typical applications will set theScenewidth instead. ThisWindowwill take its width from the scene if it has never been set by the application. Resizing the window by end user does not count as a setting the width by the application. If thisWindowis an instance ofStage, changing this attribute will not visually affect theWindowwhilefullScreenis true, but will be honored by theWindowoncefullScreenbecomes false.This property is read-only because it can be changed externally by the underlying platform. Further, setting this property might be ignored on some platforms.
- Returns:
- the
widthproperty - See Also:
-
setHeight
public final void setHeight(double value) Sets the value of theheightproperty.- Property description:
- The height of this
Window. Changing this attribute will shrink or heighten the height of theWindow. This value includes any and all decorations which may be added by the Operating System such as the title bar. Typical applications will set theSceneheight instead. This window will take its height from the scene if it has never been set by the application. Resizing this window by end user does not count as a setting the height by the application. If thisWindowis an instance ofStage, changing this attribute will not visually affect theWindowwhilefullScreenis true, but will be honored by theWindowoncefullScreenbecomes false.This property is read-only because it can be changed externally by the underlying platform. Further, setting this property might be ignored on some platforms.
- Parameters:
value- the value for theheightproperty- See Also:
-
getHeight
public final double getHeight()Gets the value of theheightproperty.- Property description:
- The height of this
Window. Changing this attribute will shrink or heighten the height of theWindow. This value includes any and all decorations which may be added by the Operating System such as the title bar. Typical applications will set theSceneheight instead. This window will take its height from the scene if it has never been set by the application. Resizing this window by end user does not count as a setting the height by the application. If thisWindowis an instance ofStage, changing this attribute will not visually affect theWindowwhilefullScreenis true, but will be honored by theWindowoncefullScreenbecomes false.This property is read-only because it can be changed externally by the underlying platform. Further, setting this property might be ignored on some platforms.
- Returns:
- the value of the
heightproperty - See Also:
-
heightProperty
The height of thisWindow. Changing this attribute will shrink or heighten the height of theWindow. This value includes any and all decorations which may be added by the Operating System such as the title bar. Typical applications will set theSceneheight instead. This window will take its height from the scene if it has never been set by the application. Resizing this window by end user does not count as a setting the height by the application. If thisWindowis an instance ofStage, changing this attribute will not visually affect theWindowwhilefullScreenis true, but will be honored by theWindowoncefullScreenbecomes false.This property is read-only because it can be changed externally by the underlying platform. Further, setting this property might be ignored on some platforms.
- Returns:
- the
heightproperty - See Also:
-
requestFocus
public final void requestFocus()Requests that thisWindowget the input focus. -
isFocused
public final boolean isFocused()Gets the value of thefocusedproperty.- Property description:
- Whether or not this
Windowhas the keyboard or input focus. - Returns:
- the value of the
focusedproperty - See Also:
-
focusedProperty
Whether or not thisWindowhas the keyboard or input focus.- Returns:
- the
focusedproperty - See Also:
-
getProperties
Returns an observable map of properties on this node for use primarily by application developers.- Returns:
- an observable map of properties on this node for use primarily by application developers
- Since:
- JavaFX 8u40
-
hasProperties
public boolean hasProperties()Tests if Window has properties.- Returns:
- true if node has properties.
- Since:
- JavaFX 8u40
-
setUserData
Convenience method for setting a single Object property that can be retrieved at a later date. This is functionally equivalent to calling the getProperties().put(Object key, Object value) method. This can later be retrieved by callinggetUserData().- Parameters:
value- The value to be stored - this can later be retrieved by callinggetUserData().- Since:
- JavaFX 8u40
-
getUserData
Returns a previously set Object property, or null if no such property has been set using thesetUserData(java.lang.Object)method.- Returns:
- The Object that was previously set, or null if no property has been set or if null was set.
- Since:
- JavaFX 8u40
-
setScene
Sets the value of thesceneproperty.The
Sceneto be rendered on thisWindow. There can only be oneSceneon theWindowat a time, and aScenecan only be on oneWindowat a time. Setting aSceneon a differentWindowwill cause the oldWindowto lose the reference before the new one gains it. You may swapScenes on aWindowat any time, even if it is an instance ofStageand withfullScreenset totrue.If the width or height of this
Windowhave never been set by the application, setting the scene will cause thisWindowto take its width or height from that scene. Resizing thisWindowby end user does not count as setting the width or height by the application.- Default value:
null- Parameters:
value- the value for thesceneproperty- Throws:
IllegalStateException- if this property is set on a thread other than the JavaFX Application Thread.- See Also:
-
getScene
Gets the value of thesceneproperty.- Property description:
- The
Sceneto be rendered on thisWindow. There can only be oneSceneon theWindowat a time, and aScenecan only be on oneWindowat a time. Setting aSceneon a differentWindowwill cause the oldWindowto lose the reference before the new one gains it. You may swapScenes on aWindowat any time, even if it is an instance ofStageand withfullScreenset totrue.If the width or height of this
Windowhave never been set by the application, setting the scene will cause thisWindowto take its width or height from that scene. Resizing thisWindowby end user does not count as setting the width or height by the application.An
IllegalStateExceptionis thrown if this property is set on a thread other than the JavaFX Application Thread. - Default value:
null- Returns:
- the value of the
sceneproperty - See Also:
-
sceneProperty
TheSceneto be rendered on thisWindow. There can only be oneSceneon theWindowat a time, and aScenecan only be on oneWindowat a time. Setting aSceneon a differentWindowwill cause the oldWindowto lose the reference before the new one gains it. You may swapScenes on aWindowat any time, even if it is an instance ofStageand withfullScreenset totrue.If the width or height of this
Windowhave never been set by the application, setting the scene will cause thisWindowto take its width or height from that scene. Resizing thisWindowby end user does not count as setting the width or height by the application.An
IllegalStateExceptionis thrown if this property is set on a thread other than the JavaFX Application Thread.- Default value:
null- Returns:
- the
sceneproperty - See Also:
-
setOpacity
public final void setOpacity(double value) Sets the value of theopacityproperty.- Property description:
- Defines the opacity of the
Windowas a value between 0.0 and 1.0. The opacity is reflected across theWindow, itsDecorationand itsScenecontent. On a JavaFX runtime platform that does not support opacity, assigning a value to this variable will have no visible difference. AWindowwith 0% opacity is fully translucent. Typically, aWindowwith 0% opacity will not receive any mouse events. - Default value:
- 1.0
- Parameters:
value- the value for theopacityproperty- See Also:
-
getOpacity
public final double getOpacity()Gets the value of theopacityproperty.- Property description:
- Defines the opacity of the
Windowas a value between 0.0 and 1.0. The opacity is reflected across theWindow, itsDecorationand itsScenecontent. On a JavaFX runtime platform that does not support opacity, assigning a value to this variable will have no visible difference. AWindowwith 0% opacity is fully translucent. Typically, aWindowwith 0% opacity will not receive any mouse events. - Default value:
- 1.0
- Returns:
- the value of the
opacityproperty - See Also:
-
opacityProperty
Defines the opacity of theWindowas a value between 0.0 and 1.0. The opacity is reflected across theWindow, itsDecorationand itsScenecontent. On a JavaFX runtime platform that does not support opacity, assigning a value to this variable will have no visible difference. AWindowwith 0% opacity is fully translucent. Typically, aWindowwith 0% opacity will not receive any mouse events.- Default value:
- 1.0
- Returns:
- the
opacityproperty - See Also:
-
setOnCloseRequest
Sets the value of theonCloseRequestproperty.- Property description:
- Called when there is an external request to close this
Window. The installed event handler can prevent window closing by consuming the received event. - Parameters:
value- the value for theonCloseRequestproperty- See Also:
-
getOnCloseRequest
Gets the value of theonCloseRequestproperty.- Property description:
- Called when there is an external request to close this
Window. The installed event handler can prevent window closing by consuming the received event. - Returns:
- the value of the
onCloseRequestproperty - See Also:
-
onCloseRequestProperty
Called when there is an external request to close thisWindow. The installed event handler can prevent window closing by consuming the received event.- Returns:
- the
onCloseRequestproperty - See Also:
-
setOnShowing
Sets the value of theonShowingproperty.- Property description:
- Called just prior to the Window being shown.
- Parameters:
value- the value for theonShowingproperty- See Also:
-
getOnShowing
Gets the value of theonShowingproperty.- Property description:
- Called just prior to the Window being shown.
- Returns:
- the value of the
onShowingproperty - See Also:
-
onShowingProperty
Called just prior to the Window being shown.- Returns:
- the
onShowingproperty - See Also:
-
setOnShown
Sets the value of theonShownproperty.- Property description:
- Called just after the Window is shown.
- Parameters:
value- the value for theonShownproperty- See Also:
-
getOnShown
Gets the value of theonShownproperty.- Property description:
- Called just after the Window is shown.
- Returns:
- the value of the
onShownproperty - See Also:
-
onShownProperty
Called just after the Window is shown.- Returns:
- the
onShownproperty - See Also:
-
setOnHiding
Sets the value of theonHidingproperty.- Property description:
- Called just prior to the Window being hidden.
- Parameters:
value- the value for theonHidingproperty- See Also:
-
getOnHiding
Gets the value of theonHidingproperty.- Property description:
- Called just prior to the Window being hidden.
- Returns:
- the value of the
onHidingproperty - See Also:
-
onHidingProperty
Called just prior to the Window being hidden.- Returns:
- the
onHidingproperty - See Also:
-
setOnHidden
Sets the value of theonHiddenproperty.- Property description:
- Called just after the Window has been hidden.
When the
Windowis hidden, this event handler is invoked allowing the developer to clean up resources or perform other tasks when theWindowis closed. - Parameters:
value- the value for theonHiddenproperty- See Also:
-
getOnHidden
Gets the value of theonHiddenproperty.- Property description:
- Called just after the Window has been hidden.
When the
Windowis hidden, this event handler is invoked allowing the developer to clean up resources or perform other tasks when theWindowis closed. - Returns:
- the value of the
onHiddenproperty - See Also:
-
onHiddenProperty
Called just after the Window has been hidden. When theWindowis hidden, this event handler is invoked allowing the developer to clean up resources or perform other tasks when theWindowis closed.- Returns:
- the
onHiddenproperty - See Also:
-
isShowing
public final boolean isShowing()Gets the value of theshowingproperty.- Property description:
- Whether or not this
Windowis showing (that is, open on the user's system). The Window might be "showing", yet the user might not be able to see it due to the Window being rendered behind another Window or due to the Window being positioned off the monitor. - Default value:
- false
- Returns:
- the value of the
showingproperty - See Also:
-
showingProperty
Whether or not thisWindowis showing (that is, open on the user's system). The Window might be "showing", yet the user might not be able to see it due to the Window being rendered behind another Window or due to the Window being positioned off the monitor.- Default value:
- false
- Returns:
- the
showingproperty - See Also:
-
show
protected void show()Attempts to show this Window by setting visibility to true- Throws:
IllegalStateException- if this method is called on a thread other than the JavaFX Application Thread.
-
hide
public void hide()Attempts to hide this Window by setting the visibility to false.- Throws:
IllegalStateException- if this method is called on a thread other than the JavaFX Application Thread.
-
setEventDispatcher
Sets the value of theeventDispatcherproperty.- Property description:
- Specifies the event dispatcher for this node. The default event
dispatcher sends the received events to the registered event handlers and
filters. When replacing the value with a new
EventDispatcher, the new dispatcher should forward events to the replaced dispatcher to maintain the node's default event handling behavior. - Parameters:
value- the value for theeventDispatcherproperty- See Also:
-
getEventDispatcher
Gets the value of theeventDispatcherproperty.- Property description:
- Specifies the event dispatcher for this node. The default event
dispatcher sends the received events to the registered event handlers and
filters. When replacing the value with a new
EventDispatcher, the new dispatcher should forward events to the replaced dispatcher to maintain the node's default event handling behavior. - Returns:
- the value of the
eventDispatcherproperty - See Also:
-
eventDispatcherProperty
Specifies the event dispatcher for this node. The default event dispatcher sends the received events to the registered event handlers and filters. When replacing the value with a newEventDispatcher, the new dispatcher should forward events to the replaced dispatcher to maintain the node's default event handling behavior.- Returns:
- the
eventDispatcherproperty - See Also:
-
addEventHandler
public final <T extends Event> void addEventHandler(EventType<T> eventType, EventHandler<? super T> eventHandler) Description copied from interface:EventTargetRegisters an event handler for this target.The handler is called when the target receives an
Eventof the specified type during the bubbling phase of event delivery.- Specified by:
addEventHandlerin interfaceEventTarget- Type Parameters:
T- the event class of the handler- Parameters:
eventType- the type of the events received by the handlereventHandler- the event handler
-
removeEventHandler
public final <T extends Event> void removeEventHandler(EventType<T> eventType, EventHandler<? super T> eventHandler) Description copied from interface:EventTargetUnregisters a previously registered event handler from this target.Since it is possible to register a single
EventHandlerinstance for different event types, the caller needs to specify the event type from which the handler should be unregistered.- Specified by:
removeEventHandlerin interfaceEventTarget- Type Parameters:
T- the event class of the handler- Parameters:
eventType- the event type from which to unregistereventHandler- the event handler
-
addEventFilter
public final <T extends Event> void addEventFilter(EventType<T> eventType, EventHandler<? super T> eventFilter) Description copied from interface:EventTargetRegisters an event filter for this target.The filter is called when the target receives an
Eventof the specified type during the capturing phase of event delivery.- Specified by:
addEventFilterin interfaceEventTarget- Type Parameters:
T- the event class of the filter- Parameters:
eventType- the type of the events received by the filtereventFilter- the event filter
-
removeEventFilter
public final <T extends Event> void removeEventFilter(EventType<T> eventType, EventHandler<? super T> eventFilter) Description copied from interface:EventTargetUnregisters a previously registered event filter from this target.Since it is possible to register a single
EventHandlerinstance for different event types, the caller needs to specify the event type from which the filter should be unregistered.- Specified by:
removeEventFilterin interfaceEventTarget- Type Parameters:
T- the event class of the filter- Parameters:
eventType- the event type from which to unregistereventFilter- the event filter
-
setEventHandler
protected final <T extends Event> void setEventHandler(EventType<T> eventType, EventHandler<? super T> eventHandler) Sets the handler to use for this event type. There can only be one such handler specified at a time. This handler is guaranteed to be called first. This is used for registering the user-defined onFoo event handlers.- Type Parameters:
T- the specific event class of the handler- Parameters:
eventType- the event type to associate with the given eventHandlereventHandler- the handler to register, or null to unregister- Throws:
NullPointerException- if the event type is null
-
fireEvent
Fires the specified event.This method must be called on the FX user thread.
- Parameters:
event- the event to fire
-
buildEventDispatchChain
Description copied from interface:EventTargetConstruct an event dispatch chain for this target. The event dispatch chain contains event dispatchers which might be interested in processing of events targeted at thisEventTarget. This event target is not automatically added to the chain, so if it wants to process events, it needs to add anEventDispatcherfor itself to the chain.In the case the event target is part of some hierarchy, the chain for it is usually built from event dispatchers collected from the root of the hierarchy to the event target.
The event dispatch chain is constructed by modifications to the provided initial event dispatch chain. The returned chain should have the initial chain at its end so the dispatchers should be prepended to the initial chain.
The caller shouldn't assume that the initial chain remains unchanged nor that the returned value will reference a different chain.
- Specified by:
buildEventDispatchChainin interfaceEventTarget- Parameters:
tail- the initial chain to build from- Returns:
- the resulting event dispatch chain for this target
-