Class Window
- All Implemented Interfaces:
HasHeightProperty
,HasSceneProperty
,HasWidthProperty
,EventTarget
- Direct Known Subclasses:
PopupWindow
,Stage
- Author:
- Bruno Salmon
-
Property Summary
TypePropertyDescriptionfinal ObjectProperty<EventDispatcher>
Specifies the event dispatcher for this node.final ReadOnlyProperty<Boolean>
Whether or not thisWindow
has the keyboard or input focus.final DoubleProperty
The height of thisStage
.final ObjectProperty<EventHandler<WindowEvent>>
Called when there is an external request to close thisWindow
.final ReadOnlyProperty<Boolean>
Whether or not thisStage
is showing (that is, open on the user's system).final DoubleProperty
The width of thisStage
.final ReadOnlyDoubleProperty
The horizontal location of thisStage
on the screen.final ReadOnlyDoubleProperty
The vertical location of thisStage
on the screen. -
Field Summary
Modifier and TypeFieldDescriptionprotected WindowPeer
The peer of this Stage.protected WindowPeerListener
The listener that gets called by peer. -
Constructor Summary
-
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.void
Sets x and y properties on this Window so that it is centered on the curent screen.protected WindowPeer
final ObjectProperty<EventDispatcher>
Specifies the event dispatcher for this node.final void
Fires the specified event.final ReadOnlyProperty<Boolean>
Whether or not thisWindow
has the keyboard or input focus.final EventDispatcher
Gets the value of theeventDispatcher
property.final EventHandler<WindowEvent>
Gets the value of theonCloseRequest
property.final double
getX()
Gets the value of thex
property.final double
getY()
Gets the value of they
property.final DoubleProperty
The height of thisStage
.void
hide()
Attempts to hide this Window by setting the visibility to false.Get Stage's peerprotected void
impl_visibleChanged
(boolean visible) This can be replaced by listening for the onShown/onHidden eventsfinal boolean
final boolean
void
notifySizeChanged
(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 void
Requests that thisWindow
get the input focus.final void
Sets the value of theeventDispatcher
property.protected final <T extends Event>
voidsetEventHandler
(EventType<T> eventType, EventHandler<? super T> eventHandler) Sets the handler to use for this event type.final void
setHeight
(double value) Sets the value of theheight
property.final void
setOnCloseRequest
(EventHandler<WindowEvent> value) Sets the value of theonCloseRequest
property.final void
setWidth
(double value) Sets the value of thewidth
property.final void
setX
(double value) Sets the value of thex
property.final void
setY
(double value) Sets the value of they
property.protected void
show()
Attempts to show this Window by setting visibility to truefinal ReadOnlyProperty<Boolean>
Whether or not thisStage
is showing (that is, open on the user's system).void
Set the width and height of this Window to match the size of the content of this Window's Scene.final DoubleProperty
The width of thisStage
.final ReadOnlyDoubleProperty
The horizontal location of thisStage
on the screen.final ReadOnlyDoubleProperty
The vertical location of thisStage
on the screen.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface dev.webfx.kit.mapper.peers.javafxgraphics.markers.HasHeightProperty
getHeight, setHeight
Methods inherited from interface dev.webfx.kit.mapper.peers.javafxgraphics.markers.HasSceneProperty
getScene, setScene
Methods inherited from interface dev.webfx.kit.mapper.peers.javafxgraphics.markers.HasWidthProperty
getWidth, setWidth
-
Property Details
-
scene
- Specified by:
sceneProperty
in interfaceHasSceneProperty
- Returns:
- the
scene
property - 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 aStage
whilefullScreen
is true, but will be honored by theStage
oncefullScreen
becomes 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 theScene
width instead.The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
- Specified by:
widthProperty
in interfaceHasWidthProperty
- Returns:
- the
width
property - 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 aStage
whilefullScreen
is true, but will be honored by theStage
oncefullScreen
becomes 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 theScene
height instead.The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
- Specified by:
heightProperty
in interfaceHasHeightProperty
- Returns:
- the
height
property - See Also:
-
x
The horizontal location of thisStage
on the screen. Changing this attribute will move theStage
horizontally. Changing this attribute will not visually affect aStage
whilefullScreen
is true, but will be honored by theStage
oncefullScreen
becomes false.- See Also:
-
y
The vertical location of thisStage
on the screen. Changing this attribute will move theStage
vertically. Changing this attribute will not visually affect aStage
whilefullScreen
is true, but will be honored by theStage
oncefullScreen
becomes false.- See Also:
-
showing
Whether or not thisStage
is 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 thisWindow
has 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:
sceneProperty
in interfaceHasSceneProperty
- Returns:
- the
scene
property - See Also:
-
setWidth
public final void setWidth(double value) Sets the value of thewidth
property.- 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 aStage
whilefullScreen
is true, but will be honored by theStage
oncefullScreen
becomes 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 theScene
width 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 thewidth
property- 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 aStage
whilefullScreen
is true, but will be honored by theStage
oncefullScreen
becomes 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 theScene
width instead.The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
- Specified by:
widthProperty
in interfaceHasWidthProperty
- Returns:
- the
width
property - See Also:
-
setHeight
public final void setHeight(double value) Sets the value of theheight
property.- 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 aStage
whilefullScreen
is true, but will be honored by theStage
oncefullScreen
becomes 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 theScene
height 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 theheight
property- 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 aStage
whilefullScreen
is true, but will be honored by theStage
oncefullScreen
becomes 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 theScene
height instead.The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
- Specified by:
heightProperty
in interfaceHasHeightProperty
- Returns:
- the
height
property - 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 thex
property.- Property description:
- The horizontal location of this
Stage
on the screen. Changing this attribute will move theStage
horizontally. Changing this attribute will not visually affect aStage
whilefullScreen
is true, but will be honored by theStage
oncefullScreen
becomes false. - Parameters:
value
- the value for thex
property- See Also:
-
getX
public final double getX()Gets the value of thex
property.- Property description:
- The horizontal location of this
Stage
on the screen. Changing this attribute will move theStage
horizontally. Changing this attribute will not visually affect aStage
whilefullScreen
is true, but will be honored by theStage
oncefullScreen
becomes false. - Returns:
- the value of the
x
property - See Also:
-
xProperty
The horizontal location of thisStage
on the screen. Changing this attribute will move theStage
horizontally. Changing this attribute will not visually affect aStage
whilefullScreen
is true, but will be honored by theStage
oncefullScreen
becomes false.- Returns:
- the
x
property - See Also:
-
setY
public final void setY(double value) Sets the value of they
property.- Property description:
- The vertical location of this
Stage
on the screen. Changing this attribute will move theStage
vertically. Changing this attribute will not visually affect aStage
whilefullScreen
is true, but will be honored by theStage
oncefullScreen
becomes false. - Parameters:
value
- the value for they
property- See Also:
-
getY
public final double getY()Gets the value of they
property.- Property description:
- The vertical location of this
Stage
on the screen. Changing this attribute will move theStage
vertically. Changing this attribute will not visually affect aStage
whilefullScreen
is true, but will be honored by theStage
oncefullScreen
becomes false. - Returns:
- the value of the
y
property - See Also:
-
yProperty
The vertical location of thisStage
on the screen. Changing this attribute will move theStage
vertically. Changing this attribute will not visually affect aStage
whilefullScreen
is true, but will be honored by theStage
oncefullScreen
becomes false.- Returns:
- the
y
property - See Also:
-
isShowing
public final boolean isShowing() -
showingProperty
Whether or not thisStage
is 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
showing
property
-
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 thisWindow
get the input focus. -
isFocused
public final boolean isFocused() -
focusedProperty
Whether or not thisWindow
has 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
focused
property - 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 theonCloseRequest
property.- 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 theonCloseRequest
property- See Also:
-
getOnCloseRequest
Gets the value of theonCloseRequest
property.- 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
onCloseRequest
property - 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
onCloseRequest
property - See Also:
-
setEventDispatcher
Sets the value of theeventDispatcher
property.- 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 theeventDispatcher
property- See Also:
-
getEventDispatcher
Gets the value of theeventDispatcher
property.- 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
eventDispatcher
property - 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
eventDispatcher
property - 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 anEvent
of 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 anEvent
of 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:
buildEventDispatchChain
in interfaceEventTarget
- Parameters:
tail
- the initial chain to build from- Returns:
- the resulting event dispatch chain for this window
-