Class Window
- javafx.stage.Window
All Implemented Interfaces:
Direct Known Subclasses:
public class Window extends Object implements EventTarget
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. A Window is used also for browser plug-in based deployments.
Since:
JavaFX 2.0
-
Property Summary
All MethodsInstance MethodsConcrete Methods Type Property and Description ObjectProperty<EventDispatcher>eventDispatcherSpecifies the event dispatcher for this node.ReadOnlyBooleanPropertyfocusedWhether or not thisWindowhas the keyboard or input focus.ReadOnlyDoublePropertyheightThe height of thisStage.ObjectProperty<EventHandler<WindowEvent>>onCloseRequestCalled when there is an external request to close thisWindow.ObjectProperty<EventHandler<WindowEvent>>onHiddenCalled just after the Window has been hidden.ObjectProperty<EventHandler<WindowEvent>>onHidingCalled just prior to the Window being hidden.ObjectProperty<EventHandler<WindowEvent>>onShowingCalled just prior to the Window being shown.ObjectProperty<EventHandler<WindowEvent>>onShownCalled just after the Window is shown.DoublePropertyopacityDefines the opacity of theStageas a value between 0.0 and 1.0.ReadOnlyObjectProperty<Scene>sceneTheSceneto be rendered on thisStage.ReadOnlyBooleanPropertyshowingWhether or not thisStageis showing (that is, open on the user's system).ReadOnlyDoublePropertywidthThe width of thisStage.ReadOnlyDoublePropertyxThe horizontal location of thisStageon the screen.ReadOnlyDoublePropertyyThe vertical location of thisStageon the screen.
-
Constructor Summary
Constructors Modifier Constructor and Description protectedWindow()
-
Method Summary
All MethodsInstance MethodsConcrete Methods Modifier and Type Method and Description <T extends Event>
voidaddEventFilter(EventType<T> eventType, EventHandler<? super T> eventFilter)Registers an event filter to this node.<T extends Event>
voidaddEventHandler(EventType<T> eventType, EventHandler<? super T> eventHandler)Registers an event handler to this node.EventDispatchChainbuildEventDispatchChain(EventDispatchChain tail)Construct an event dispatch chain for this window.voidcenterOnScreen()Sets x and y properties on this Window so that it is centered on the curent screen.ObjectProperty<EventDispatcher>eventDispatcherProperty()Specifies the event dispatcher for this node.voidfireEvent(Event event)Fires the specified event.ReadOnlyBooleanPropertyfocusedProperty()Whether or not thisWindowhas the keyboard or input focus.EventDispatchergetEventDispatcher()Gets the value of the property eventDispatcher.doublegetHeight()Gets the value of the property height.EventHandler<WindowEvent>getOnCloseRequest()Gets the value of the property onCloseRequest.EventHandler<WindowEvent>getOnHidden()Gets the value of the property onHidden.EventHandler<WindowEvent>getOnHiding()Gets the value of the property onHiding.EventHandler<WindowEvent>getOnShowing()Gets the value of the property onShowing.EventHandler<WindowEvent>getOnShown()Gets the value of the property onShown.doublegetOpacity()Gets the value of the property opacity.ObservableMap<Object,Object>getProperties()Returns an observable map of properties on this node for use primarily by application developers.ScenegetScene()Gets the value of the property scene.ObjectgetUserData()Returns a previously set Object property, or null if no such property has been set using thesetUserData(java.lang.Object)method.doublegetWidth()Gets the value of the property width.doublegetX()Gets the value of the property x.doublegetY()Gets the value of the property y.booleanhasProperties()Tests if Window has properties.ReadOnlyDoublePropertyheightProperty()The height of thisStage.voidhide()Attempts to hide this Window by setting the visibility to false.booleanisFocused()Gets the value of the property focused.booleanisShowing()Gets the value of the property showing.ObjectProperty<EventHandler<WindowEvent>>onCloseRequestProperty()Called when there is an external request to close thisWindow.ObjectProperty<EventHandler<WindowEvent>>onHiddenProperty()Called just after the Window has been hidden.ObjectProperty<EventHandler<WindowEvent>>onHidingProperty()Called just prior to the Window being hidden.ObjectProperty<EventHandler<WindowEvent>>onShowingProperty()Called just prior to the Window being shown.ObjectProperty<EventHandler<WindowEvent>>onShownProperty()Called just after the Window is shown.DoublePropertyopacityProperty()Defines the opacity of theStageas a value between 0.0 and 1.0.<T extends Event>
voidremoveEventFilter(EventType<T> eventType, EventHandler<? super T> eventFilter)Unregisters a previously registered event filter from this node.<T extends Event>
voidremoveEventHandler(EventType<T> eventType, EventHandler<? super T> eventHandler)Unregisters a previously registered event handler from this node.voidrequestFocus()Requests that thisWindowget the input focus.ReadOnlyObjectProperty<Scene>sceneProperty()TheSceneto be rendered on thisStage.voidsetEventDispatcher(EventDispatcher value)Sets the value of the property eventDispatcher.protected <T extends Event>
voidsetEventHandler(EventType<T> eventType, EventHandler<? super T> eventHandler)Sets the handler to use for this event type.voidsetHeight(double value)Sets the value of the property height.voidsetOnCloseRequest(EventHandler<WindowEvent> value)Sets the value of the property onCloseRequest.voidsetOnHidden(EventHandler<WindowEvent> value)Sets the value of the property onHidden.voidsetOnHiding(EventHandler<WindowEvent> value)Sets the value of the property onHiding.voidsetOnShowing(EventHandler<WindowEvent> value)Sets the value of the property onShowing.voidsetOnShown(EventHandler<WindowEvent> value)Sets the value of the property onShown.voidsetOpacity(double value)Sets the value of the property opacity.protected voidsetScene(Scene value)Sets the value of the property scene.voidsetUserData(Object value)Convenience method for setting a single Object property that can be retrieved at a later date.voidsetWidth(double value)Sets the value of the property width.voidsetX(double value)Sets the value of the property x.voidsetY(double value)Sets the value of the property y.protected voidshow()Attempts to show this Window by setting visibility to trueReadOnlyBooleanPropertyshowingProperty()Whether or not thisStageis showing (that is, open on the user's system).voidsizeToScene()Set the width and height of this Window to match the size of the content of this Window's Scene.ReadOnlyDoublePropertywidthProperty()The width of thisStage.ReadOnlyDoublePropertyxProperty()The horizontal location of thisStageon the screen.ReadOnlyDoublePropertyyProperty()The vertical location of thisStageon the screen.
-
Property Detail
-
x
public final ReadOnlyDoubleProperty 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.See Also:
-
y
public final ReadOnlyDoubleProperty 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.See Also:
-
width
public final ReadOnlyDoubleProperty 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.
See Also:
-
height
public final ReadOnlyDoubleProperty 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.
See Also:
-
focused
public final ReadOnlyBooleanProperty 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.
See Also:
-
scene
public final ReadOnlyObjectProperty<Scene> sceneProperty
TheSceneto be rendered on thisStage. There can only be oneSceneon theStageat a time, and aScenecan only be on oneStageat a time. Setting aSceneon a differentStagewill cause the oldStageto lose the reference before the new one gains it. You may swapScenes on aStageat any time, even while in full-screen exclusive mode. AnIllegalStateExceptionis thrown if this property is set on a thread other than the JavaFX Application Thread.Default value:
null
See Also:
-
opacity
public final DoubleProperty opacityProperty
Defines the opacity of theStageas a value between 0.0 and 1.0. The opacity is reflected across theStage, itsDecorationand itsScenecontent. On a JavaFX runtime platform that does not support opacity, assigning a value to this variable will have no visible difference. AStagewith 0% opacity is fully translucent. Typically, aStagewith 0% opacity will not receive any mouse events.Default value:
1.0
See Also:
-
onCloseRequest
public final ObjectProperty<EventHandler<WindowEvent>> onCloseRequestProperty
Called when there is an external request to close thisWindow. The installed event handler can prevent window closing by consuming the received event.
-
onShowing
public final ObjectProperty<EventHandler<WindowEvent>> onShowingProperty
Called just prior to the Window being shown.See Also:
-
onShown
public final ObjectProperty<EventHandler<WindowEvent>> onShownProperty
Called just after the Window is shown.See Also:
-
onHiding
public final ObjectProperty<EventHandler<WindowEvent>> onHidingProperty
Called just prior to the Window being hidden.See Also:
-
onHidden
public final ObjectProperty<EventHandler<WindowEvent>> 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.See Also:
-
showing
public final ReadOnlyBooleanProperty 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
See Also:
-
eventDispatcher
public final ObjectProperty<EventDispatcher> 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.
-
-
Constructor Detail
-
Window
protected Window()
-
-
Method Detail
-
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.
-
setX
public final void setX(double value)
Sets the value of the property x.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.
-
getX
public final double getX()
Gets the value of the property x.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.
-
xProperty
public final ReadOnlyDoubleProperty 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.See Also:
-
setY
public final void setY(double value)
Sets the value of the property y.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.
-
getY
public final double getY()
Gets the value of the property y.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.
-
yProperty
public final ReadOnlyDoubleProperty 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.See Also:
-
setWidth
public final void setWidth(double value)
Sets the value of the property width.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.
-
getWidth
public final double getWidth()
Gets the value of the property width.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.
-
widthProperty
public final ReadOnlyDoubleProperty 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.
See Also:
-
setHeight
public final void setHeight(double value)
Sets the value of the property height.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.
-
getHeight
public final double getHeight()
Gets the value of the property height.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.
-
heightProperty
public final ReadOnlyDoubleProperty 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.
See Also:
-
requestFocus
public final void requestFocus()
Requests that thisWindowget the input focus.
-
isFocused
public final boolean isFocused()
Gets the value of the property focused.Property description:
Whether or not this
Windowhas 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.
-
focusedProperty
public final ReadOnlyBooleanProperty 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.
See Also:
-
getProperties
public final ObservableMap<Object,Object> 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
public void setUserData(Object value)
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
public Object 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
protected void setScene(Scene value)
Sets the value of the property scene.Property description:
The
Sceneto be rendered on thisStage. There can only be oneSceneon theStageat a time, and aScenecan only be on oneStageat a time. Setting aSceneon a differentStagewill cause the oldStageto lose the reference before the new one gains it. You may swapScenes on aStageat any time, even while in full-screen exclusive mode. AnIllegalStateExceptionis thrown if this property is set on a thread other than the JavaFX Application Thread.Default value:
null
-
getScene
public final Scene getScene()
Gets the value of the property scene.Property description:
The
Sceneto be rendered on thisStage. There can only be oneSceneon theStageat a time, and aScenecan only be on oneStageat a time. Setting aSceneon a differentStagewill cause the oldStageto lose the reference before the new one gains it. You may swapScenes on aStageat any time, even while in full-screen exclusive mode. AnIllegalStateExceptionis thrown if this property is set on a thread other than the JavaFX Application Thread.Default value:
null
-
sceneProperty
public final ReadOnlyObjectProperty<Scene> sceneProperty()
TheSceneto be rendered on thisStage. There can only be oneSceneon theStageat a time, and aScenecan only be on oneStageat a time. Setting aSceneon a differentStagewill cause the oldStageto lose the reference before the new one gains it. You may swapScenes on aStageat any time, even while in full-screen exclusive mode. AnIllegalStateExceptionis thrown if this property is set on a thread other than the JavaFX Application Thread.Default value:
null
See Also:
-
setOpacity
public final void setOpacity(double value)
Sets the value of the property opacity.Property description:
Defines the opacity of the
Stageas a value between 0.0 and 1.0. The opacity is reflected across theStage, itsDecorationand itsScenecontent. On a JavaFX runtime platform that does not support opacity, assigning a value to this variable will have no visible difference. AStagewith 0% opacity is fully translucent. Typically, aStagewith 0% opacity will not receive any mouse events.Default value:
1.0
-
getOpacity
public final double getOpacity()
Gets the value of the property opacity.Property description:
Defines the opacity of the
Stageas a value between 0.0 and 1.0. The opacity is reflected across theStage, itsDecorationand itsScenecontent. On a JavaFX runtime platform that does not support opacity, assigning a value to this variable will have no visible difference. AStagewith 0% opacity is fully translucent. Typically, aStagewith 0% opacity will not receive any mouse events.Default value:
1.0
-
opacityProperty
public final DoubleProperty opacityProperty()
Defines the opacity of theStageas a value between 0.0 and 1.0. The opacity is reflected across theStage, itsDecorationand itsScenecontent. On a JavaFX runtime platform that does not support opacity, assigning a value to this variable will have no visible difference. AStagewith 0% opacity is fully translucent. Typically, aStagewith 0% opacity will not receive any mouse events.Default value:
1.0
See Also:
-
setOnCloseRequest
public final void setOnCloseRequest(EventHandler<WindowEvent> value)
Sets the value of the property onCloseRequest.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.
-
getOnCloseRequest
public final EventHandler<WindowEvent> getOnCloseRequest()
Gets the value of the property onCloseRequest.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.
-
onCloseRequestProperty
public final ObjectProperty<EventHandler<WindowEvent>> onCloseRequestProperty()
Called when there is an external request to close thisWindow. The installed event handler can prevent window closing by consuming the received event.
-
setOnShowing
public final void setOnShowing(EventHandler<WindowEvent> value)
Sets the value of the property onShowing.Property description:
Called just prior to the Window being shown.
-
getOnShowing
public final EventHandler<WindowEvent> getOnShowing()
Gets the value of the property onShowing.Property description:
Called just prior to the Window being shown.
-
onShowingProperty
public final ObjectProperty<EventHandler<WindowEvent>> onShowingProperty()
Called just prior to the Window being shown.See Also:
-
setOnShown
public final void setOnShown(EventHandler<WindowEvent> value)
Sets the value of the property onShown.Property description:
Called just after the Window is shown.
-
getOnShown
public final EventHandler<WindowEvent> getOnShown()
Gets the value of the property onShown.Property description:
Called just after the Window is shown.
-
onShownProperty
public final ObjectProperty<EventHandler<WindowEvent>> onShownProperty()
Called just after the Window is shown.See Also:
-
setOnHiding
public final void setOnHiding(EventHandler<WindowEvent> value)
Sets the value of the property onHiding.Property description:
Called just prior to the Window being hidden.
-
getOnHiding
public final EventHandler<WindowEvent> getOnHiding()
Gets the value of the property onHiding.Property description:
Called just prior to the Window being hidden.
-
onHidingProperty
public final ObjectProperty<EventHandler<WindowEvent>> onHidingProperty()
Called just prior to the Window being hidden.See Also:
-
setOnHidden
public final void setOnHidden(EventHandler<WindowEvent> value)
Sets the value of the property onHidden.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.
-
getOnHidden
public final EventHandler<WindowEvent> getOnHidden()
Gets the value of the property onHidden.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.
-
onHiddenProperty
public final ObjectProperty<EventHandler<WindowEvent>> 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.See Also:
-
isShowing
public final boolean isShowing()
Gets the value of the property showing.Property description:
Whether or not this
Stageis 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
-
showingProperty
public final ReadOnlyBooleanProperty 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
See Also:
-
show
protected void show()
Attempts to show this Window by setting visibility to trueThrows:
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
public final void setEventDispatcher(EventDispatcher value)
Sets the value of the property eventDispatcher.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.
-
getEventDispatcher
public final EventDispatcher getEventDispatcher()
Gets the value of the property eventDispatcher.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.
-
eventDispatcherProperty
public final ObjectProperty<EventDispatcher> 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.
-
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 handlerParameters:
eventType- the type of the events to receive by the handlerThrows:
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 handlerParameters:
eventType- the event type from which to unregisterThrows:
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 filterParameters:
eventType- the type of the events to receive by the filterThrows:
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 filterParameters:
eventType- the event type from which to unregisterThrows:
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 handlerParameters:
eventType- the event type to associate with the given eventHandlerThrows:
NullPointerException- if the event type is null
-
fireEvent
public final void fireEvent(Event event)
Fires the specified event.This method must be called on the FX user thread.
Parameters:
event- the event to fire
-
buildEventDispatchChain
public EventDispatchChain buildEventDispatchChain(EventDispatchChain tail)
Construct an event dispatch chain for this window.Specified by:
buildEventDispatchChainin interfaceEventTargetParameters:
tail- the initial chain to build fromReturns:
the resulting event dispatch chain for this window
-
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.