Class Window
- All Implemented Interfaces:
HasHeightProperty,HasSceneProperty,HasWidthProperty,EventTarget
- Direct Known Subclasses:
PopupWindow,Stage
- Author:
- Bruno Salmon
-
Property Summary
PropertiesTypePropertyDescriptionfinal ObjectProperty<EventDispatcher>Specifies the event dispatcher for this node.final ReadOnlyProperty<Boolean>Whether or not thisWindowhas the keyboard or input focus.final DoublePropertyThe height of thisStage.final ObjectProperty<EventHandler<WindowEvent>>Called when there is an external request to close thisWindow.final ReadOnlyProperty<Boolean>Whether or not thisStageis showing (that is, open on the user's system).final DoublePropertyThe width of thisStage.final ReadOnlyDoublePropertyThe horizontal location of thisStageon the screen.final ReadOnlyDoublePropertyThe vertical location of thisStageon the screen. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected WindowPeerThe peer of this Stage.protected WindowPeerListenerThe listener that gets called by peer. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal <T extends Event>
voidaddEventFilter(EventType<T> eventType, EventHandler<? super T> eventFilter) Registers an event filter to this node.final <T extends Event>
voidaddEventHandler(EventType<T> eventType, EventHandler<? super T> eventHandler) Registers an event handler to this node.Construct an event dispatch chain for this window.voidSets x and y properties on this Window so that it is centered on the curent screen.protected WindowPeerfinal ObjectProperty<EventDispatcher>Specifies the event dispatcher for this node.final voidFires the specified event.final ReadOnlyProperty<Boolean>Whether or not thisWindowhas the keyboard or input focus.final EventDispatcherGets the value of theeventDispatcherproperty.final EventHandler<WindowEvent>Gets the value of theonCloseRequestproperty.final doublegetX()Gets the value of thexproperty.final doublegetY()Gets the value of theyproperty.final DoublePropertyThe height of thisStage.voidhide()Attempts to hide this Window by setting the visibility to false.Get Stage's peerprotected voidimpl_visibleChanged(boolean visible) This can be replaced by listening for the onShown/onHidden eventsfinal booleanfinal booleanvoidnotifySizeChanged(double newWidth, double newHeight) Notification from the windowing system that the window's size has changed.final ObjectProperty<EventHandler<WindowEvent>>Called when there is an external request to close thisWindow.final <T extends Event>
voidremoveEventFilter(EventType<T> eventType, EventHandler<? super T> eventFilter) Unregisters a previously registered event filter from this node.final <T extends Event>
voidremoveEventHandler(EventType<T> eventType, EventHandler<? super T> eventHandler) Unregisters a previously registered event handler from this node.final voidRequests that thisWindowget the input focus.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 voidsetHeight(double value) Sets the value of theheightproperty.final voidsetOnCloseRequest(EventHandler<WindowEvent> value) Sets the value of theonCloseRequestproperty.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 ReadOnlyProperty<Boolean>Whether or not thisStageis 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 DoublePropertyThe width of thisStage.final ReadOnlyDoublePropertyThe horizontal location of thisStageon the screen.final ReadOnlyDoublePropertyThe vertical location of thisStageon the screen.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.webfx.kit.mapper.peers.javafxgraphics.markers.HasHeightProperty
getHeight, setHeightMethods inherited from interface dev.webfx.kit.mapper.peers.javafxgraphics.markers.HasSceneProperty
getScene, setSceneMethods inherited from interface dev.webfx.kit.mapper.peers.javafxgraphics.markers.HasWidthProperty
getWidth, setWidth
-
Property Details
-
scene
- Specified by:
scenePropertyin interfaceHasSceneProperty- Returns:
- the
sceneproperty - See Also:
-
width
The width of thisStage. Changing this attribute will narrow or widen the width of theStage. Changing this attribute will not visually affect aStagewhilefullScreenis true, but will be honored by theStageoncefullScreenbecomes false. 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.The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
- Specified by:
widthPropertyin interfaceHasWidthProperty- Returns:
- the
widthproperty - See Also:
-
height
The height of thisStage. Changing this attribute will shrink or heighten the height of theStage. Changing this attribute will not visually affect aStagewhilefullScreenis true, but will be honored by theStageoncefullScreenbecomes false. 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.The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
- Specified by:
heightPropertyin interfaceHasHeightProperty- Returns:
- the
heightproperty - See Also:
-
x
The horizontal location of thisStageon the screen. Changing this attribute will move theStagehorizontally. Changing this attribute will not visually affect aStagewhilefullScreenis true, but will be honored by theStageoncefullScreenbecomes false.- See Also:
-
y
The vertical location of thisStageon the screen. Changing this attribute will move theStagevertically. Changing this attribute will not visually affect aStagewhilefullScreenis true, but will be honored by theStageoncefullScreenbecomes false.- See Also:
-
showing
Whether or not thisStageis showing (that is, open on the user's system). The Stage might be "showing", yet the user might not be able to see it due to the Stage being rendered behind another window or due to the Stage being positioned off the monitor.- Default value:
- false
- See Also:
-
focused
Whether or not thisWindowhas the keyboard or input focus.The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
- See Also:
-
setFocused(boolean)focusedProperty()
-
onCloseRequest
Called when there is an external request to close thisWindow. The installed event handler can prevent window closing by consuming the received event. -
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.
-
-
Field Details
-
peerListener
The listener that gets called by peer. It's also responsible for window size/location synchronization with the window peer, which occurs on every pulse. -
impl_peer
The peer of this Stage. All external access should be made though getPeer(). Implementors note: Please ensure that this variable is defined *after* style and *before* the other variables so that style has been initialized prior to this call, and so that impl_peer is initialized prior to subsequent initialization.
-
-
Constructor Details
-
Window
public Window()
-
-
Method Details
-
impl_getPeer
Get Stage's peer -
createPeer
-
sceneProperty
- Specified by:
scenePropertyin interfaceHasSceneProperty- Returns:
- the
sceneproperty - See Also:
-
setWidth
public final void setWidth(double value) Sets the value of thewidthproperty.- Property description:
- The width of this
Stage. Changing this attribute will narrow or widen the width of theStage. Changing this attribute will not visually affect aStagewhilefullScreenis true, but will be honored by theStageoncefullScreenbecomes false. 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.The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
- Parameters:
value- the value for thewidthproperty- See Also:
-
widthProperty
The width of thisStage. Changing this attribute will narrow or widen the width of theStage. Changing this attribute will not visually affect aStagewhilefullScreenis true, but will be honored by theStageoncefullScreenbecomes false. 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.The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
- Specified by:
widthPropertyin interfaceHasWidthProperty- Returns:
- the
widthproperty - See Also:
-
setHeight
public final void setHeight(double value) Sets the value of theheightproperty.- Property description:
- The height of this
Stage. Changing this attribute will shrink or heighten the height of theStage. Changing this attribute will not visually affect aStagewhilefullScreenis true, but will be honored by theStageoncefullScreenbecomes false. 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.The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
- Parameters:
value- the value for theheightproperty- See Also:
-
heightProperty
The height of thisStage. Changing this attribute will shrink or heighten the height of theStage. Changing this attribute will not visually affect aStagewhilefullScreenis true, but will be honored by theStageoncefullScreenbecomes false. 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.The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
- Specified by:
heightPropertyin interfaceHasHeightProperty- Returns:
- the
heightproperty - See Also:
-
notifySizeChanged
public void notifySizeChanged(double newWidth, double newHeight) Notification from the windowing system that the window's size has changed.- Parameters:
newWidth- the new window widthnewHeight- the new window height
-
setX
public final void setX(double value) Sets the value of thexproperty.- Property description:
- The horizontal location of this
Stageon the screen. Changing this attribute will move theStagehorizontally. Changing this attribute will not visually affect aStagewhilefullScreenis true, but will be honored by theStageoncefullScreenbecomes false. - 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
Stageon the screen. Changing this attribute will move theStagehorizontally. Changing this attribute will not visually affect aStagewhilefullScreenis true, but will be honored by theStageoncefullScreenbecomes false. - Returns:
- the value of the
xproperty - See Also:
-
xProperty
The horizontal location of thisStageon the screen. Changing this attribute will move theStagehorizontally. Changing this attribute will not visually affect aStagewhilefullScreenis true, but will be honored by theStageoncefullScreenbecomes false.- Returns:
- the
xproperty - See Also:
-
setY
public final void setY(double value) Sets the value of theyproperty.- Property description:
- The vertical location of this
Stageon the screen. Changing this attribute will move theStagevertically. Changing this attribute will not visually affect aStagewhilefullScreenis true, but will be honored by theStageoncefullScreenbecomes false. - 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
Stageon the screen. Changing this attribute will move theStagevertically. Changing this attribute will not visually affect aStagewhilefullScreenis true, but will be honored by theStageoncefullScreenbecomes false. - Returns:
- the value of the
yproperty - See Also:
-
yProperty
The vertical location of thisStageon the screen. Changing this attribute will move theStagevertically. Changing this attribute will not visually affect aStagewhilefullScreenis true, but will be honored by theStageoncefullScreenbecomes false.- Returns:
- the
yproperty - See Also:
-
isShowing
public final boolean isShowing() -
showingProperty
Whether or not thisStageis showing (that is, open on the user's system). The Stage might be "showing", yet the user might not be able to see it due to the Stage being rendered behind another window or due to the Stage being positioned off the monitor.- Default value:
- false
- Returns:
- the
showingproperty
-
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.
-
impl_visibleChanged
protected void impl_visibleChanged(boolean visible) This can be replaced by listening for the onShown/onHidden events -
requestFocus
public final void requestFocus()Requests that thisWindowget the input focus. -
isFocused
public final boolean isFocused() -
focusedProperty
Whether or not thisWindowhas the keyboard or input focus.The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
- Returns:
- the
focusedproperty - See Also:
-
setFocused(boolean)
-
sizeToScene
public void sizeToScene()Set the width and height of this Window to match the size of the content of this Window's Scene. -
centerOnScreen
public void centerOnScreen()Sets x and y properties on this Window so that it is centered on the curent screen. The current screen is determined from the intersection of current window bounds and visual bounds of all screens. -
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:
-
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) Registers an event handler to this node. The handler is called when the node receives anEventof the specified type during the bubbling phase of event delivery.- Type Parameters:
T- the specific event class of the handler- Parameters:
eventType- the type of the events to receive by the handlereventHandler- the handler to register- Throws:
NullPointerException- if the event type or handler is null
-
removeEventHandler
public final <T extends Event> void removeEventHandler(EventType<T> eventType, EventHandler<? super T> eventHandler) Unregisters a previously registered event handler from this node. One handler might have been registered for different event types, so the caller needs to specify the particular event type from which to unregister the handler.- Type Parameters:
T- the specific event class of the handler- Parameters:
eventType- the event type from which to unregistereventHandler- the handler to unregister- Throws:
NullPointerException- if the event type or handler is null
-
addEventFilter
public final <T extends Event> void addEventFilter(EventType<T> eventType, EventHandler<? super T> eventFilter) Registers an event filter to this node. The filter is called when the node receives anEventof the specified type during the capturing phase of event delivery.- Type Parameters:
T- the specific event class of the filter- Parameters:
eventType- the type of the events to receive by the filtereventFilter- the filter to register- Throws:
NullPointerException- if the event type or filter is null
-
removeEventFilter
public final <T extends Event> void removeEventFilter(EventType<T> eventType, EventHandler<? super T> eventFilter) Unregisters a previously registered event filter from this node. One filter might have been registered for different event types, so the caller needs to specify the particular event type from which to unregister the filter.- Type Parameters:
T- the specific event class of the filter- Parameters:
eventType- the event type from which to unregistereventFilter- the filter to unregister- Throws:
NullPointerException- if the event type or filter is null
-
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
Construct an event dispatch chain for this window.- Specified by:
buildEventDispatchChainin interfaceEventTarget- Parameters:
tail- the initial chain to build from- Returns:
- the resulting event dispatch chain for this window
-