public class Window extends java.lang.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.
Modifier and Type | Class and Description |
---|---|
private class |
Window.SceneModel |
private class |
Window.TKBoundsConfigurator
Caches all requested bounds settings and applies them at once during
the next pulse.
|
Modifier and Type | Field and Description |
---|---|
(package private) java.security.AccessControlContext |
acc |
private static float |
CENTER_ON_SCREEN_X_FRACTION |
private static float |
CENTER_ON_SCREEN_Y_FRACTION |
private ObjectProperty<EventDispatcher> |
eventDispatcher
Specifies the event dispatcher for this node.
|
private ReadOnlyBooleanWrapper |
focused
Whether or not this
Window has the keyboard or input focus. |
private int |
focusGrabCounter |
(package private) boolean |
hasBeenVisible |
private ReadOnlyDoubleWrapper |
height
The height of this
Window . |
private boolean |
heightExplicit |
protected TKStage |
impl_peer
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
private WindowEventDispatcher |
internalEventDispatcher |
private ObjectProperty<EventHandler<WindowEvent>> |
onCloseRequest
Called when there is an external request to close this
Window . |
private ObjectProperty<EventHandler<WindowEvent>> |
onHidden
Called just after the Window has been hidden.
|
private ObjectProperty<EventHandler<WindowEvent>> |
onHiding
Called just prior to the Window being hidden.
|
private ObjectProperty<EventHandler<WindowEvent>> |
onShowing
Called just prior to the Window being shown.
|
private ObjectProperty<EventHandler<WindowEvent>> |
onShown
Called just after the Window is shown.
|
private DoubleProperty |
opacity
Defines the opacity of the
Window as a value between 0.0 and 1.0. |
private Window.TKBoundsConfigurator |
peerBoundsConfigurator |
protected WindowPeerListener |
peerListener
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
private ObservableMap<java.lang.Object,java.lang.Object> |
properties |
private Window.SceneModel |
scene
The
Scene to be rendered on this Window . |
private ReadOnlyObjectWrapper<Screen> |
screen |
private ReadOnlyBooleanWrapper |
showing
Whether or not this
Window is showing (that is, open on the
user's system). |
private boolean |
sizeToScene
Indicates if a user requested the window to be sized to match the scene
size.
|
private static java.lang.Object |
USER_DATA_KEY
*
*
*
|
private ReadOnlyDoubleWrapper |
width
The width of this
Window . |
private boolean |
widthExplicit |
private static WeakReferenceQueue<Window> |
windowQueue
A list of all the currently existing windows.
|
private ReadOnlyDoubleWrapper |
x
The horizontal location of this
Window on the screen. |
private boolean |
xExplicit |
private ReadOnlyDoubleWrapper |
y
The vertical location of this
Window on the screen. |
private boolean |
yExplicit |
Modifier | Constructor and Description |
---|---|
protected |
Window() |
Modifier and Type | Method and Description |
---|---|
<T extends Event> |
addEventFilter(EventType<T> eventType,
EventHandler<? super T> eventFilter)
Registers an event filter to this node.
|
<T extends Event> |
addEventHandler(EventType<T> eventType,
EventHandler<? super T> eventHandler)
Registers an event handler to this node.
|
private void |
adjustSize(boolean selfSizePriority) |
(package private) void |
applyBounds() |
EventDispatchChain |
buildEventDispatchChain(EventDispatchChain tail)
Construct an event dispatch chain for this window.
|
void |
centerOnScreen()
Sets x and y properties on this Window so that it is centered on the
curent screen.
|
(package private) WindowEventDispatcher |
createInternalEventDispatcher() |
(package private) void |
decreaseFocusGrabCounter() |
ObjectProperty<EventDispatcher> |
eventDispatcherProperty() |
void |
fireEvent(Event event)
Fires the specified event.
|
private void |
focusChanged(boolean newIsFocused) |
ReadOnlyBooleanProperty |
focusedProperty() |
EventDispatcher |
getEventDispatcher() |
double |
getHeight() |
(package private) WindowEventDispatcher |
getInternalEventDispatcher() |
EventHandler<WindowEvent> |
getOnCloseRequest() |
EventHandler<WindowEvent> |
getOnHidden() |
EventHandler<WindowEvent> |
getOnHiding() |
EventHandler<WindowEvent> |
getOnShowing() |
EventHandler<WindowEvent> |
getOnShown() |
double |
getOpacity() |
ObservableMap<java.lang.Object,java.lang.Object> |
getProperties()
Returns an observable map of properties on this node for use primarily
by application developers.
|
Scene |
getScene() |
java.lang.Object |
getUserData()
Returns a previously set Object property, or null if no such property
has been set using the
setUserData(java.lang.Object) method. |
double |
getWidth() |
(package private) Window |
getWindowOwner() |
private Screen |
getWindowScreen() |
double |
getX() |
double |
getY() |
boolean |
hasProperties()
Tests if Window has properties.
|
ReadOnlyDoubleProperty |
heightProperty() |
void |
hide()
Attempts to hide this Window by setting the visibility to false.
|
java.lang.String |
impl_getMXWindowType()
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
TKStage |
impl_getPeer()
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
static java.util.Iterator<Window> |
impl_getWindows()
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
protected void |
impl_visibleChanged(boolean visible)
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
protected void |
impl_visibleChanging(boolean visible)
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
(package private) void |
increaseFocusGrabCounter() |
private void |
initializeInternalEventDispatcher() |
boolean |
isFocused() |
boolean |
isShowing() |
(package private) void |
notifyLocationChanged(double newX,
double newY)
Notification from the windowing system that the window's position has
changed.
|
private void |
notifyScreenChanged(java.lang.Object from,
java.lang.Object to) |
(package private) void |
notifySizeChanged(double newWidth,
double newHeight)
Notification from the windowing system that the window's size has
changed.
|
ObjectProperty<EventHandler<WindowEvent>> |
onCloseRequestProperty() |
ObjectProperty<EventHandler<WindowEvent>> |
onHiddenProperty() |
ObjectProperty<EventHandler<WindowEvent>> |
onHidingProperty() |
ObjectProperty<EventHandler<WindowEvent>> |
onShowingProperty() |
ObjectProperty<EventHandler<WindowEvent>> |
onShownProperty() |
DoubleProperty |
opacityProperty() |
<T extends Event> |
removeEventFilter(EventType<T> eventType,
EventHandler<? super T> eventFilter)
Unregisters a previously registered event filter from this node.
|
<T extends Event> |
removeEventHandler(EventType<T> eventType,
EventHandler<? super T> eventHandler)
Unregisters a previously registered event handler from this node.
|
void |
requestFocus()
Requests that this
Window get the input focus. |
ReadOnlyObjectProperty<Scene> |
sceneProperty() |
private ReadOnlyObjectProperty<Screen> |
screenProperty() |
void |
setEventDispatcher(EventDispatcher value) |
protected <T extends Event> |
setEventHandler(EventType<T> eventType,
EventHandler<? super T> eventHandler)
Sets the handler to use for this event type.
|
void |
setFocused(boolean value)
Deprecated.
|
void |
setHeight(double value) |
void |
setOnCloseRequest(EventHandler<WindowEvent> value) |
void |
setOnHidden(EventHandler<WindowEvent> value) |
void |
setOnHiding(EventHandler<WindowEvent> value) |
void |
setOnShowing(EventHandler<WindowEvent> value) |
void |
setOnShown(EventHandler<WindowEvent> value) |
void |
setOpacity(double value) |
protected void |
setScene(Scene value) |
private void |
setShowing(boolean value) |
void |
setUserData(java.lang.Object value)
Convenience method for setting a single Object property that can be
retrieved at a later date.
|
void |
setWidth(double value) |
void |
setX(double value) |
(package private) void |
setXInternal(double value) |
void |
setY(double value) |
(package private) void |
setYInternal(double value) |
protected void |
show()
Attempts to show this Window by setting visibility to true
|
ReadOnlyBooleanProperty |
showingProperty() |
void |
sizeToScene()
Set the width and height of this Window to match the size of the content
of this Window's Scene.
|
ReadOnlyDoubleProperty |
widthProperty() |
ReadOnlyDoubleProperty |
xProperty() |
ReadOnlyDoubleProperty |
yProperty() |
private static WeakReferenceQueue<Window> windowQueue
final java.security.AccessControlContext acc
@Deprecated protected WindowPeerListener peerListener
@Deprecated protected volatile TKStage impl_peer
private Window.TKBoundsConfigurator peerBoundsConfigurator
private boolean sizeToScene
private static final float CENTER_ON_SCREEN_X_FRACTION
private static final float CENTER_ON_SCREEN_Y_FRACTION
private boolean xExplicit
private ReadOnlyDoubleWrapper x
Window
on the screen. Changing
this attribute will move the Window
horizontally. If this
Window
is an instance of Stage
, changing this attribute
will not visually affect the Window
while
fullScreen
is true, but will be honored
by the Window
once fullScreen
becomes false.private boolean yExplicit
private ReadOnlyDoubleWrapper y
Window
on the screen. Changing this
attribute will move the Window
vertically. If this
Window
is an instance of Stage
, changing this attribute
will not visually affect the Window
while
fullScreen
is true, but will be honored
by the Window
once fullScreen
becomes false.private boolean widthExplicit
private ReadOnlyDoubleWrapper width
Window
. Changing this attribute will narrow or
widen the width of the Window
. This value includes any and all
decorations which may be added by the Operating System such as resizable
frame handles. Typical applications will set the Scene
width instead. This Window
will 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 this
Window
is an instance of Stage
, changing this attribute
will not visually affect the Window
while
fullScreen
is true, but will be honored
by the Window
once fullScreen
becomes false.
The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
private boolean heightExplicit
private ReadOnlyDoubleWrapper height
Window
. Changing this attribute will shrink
or heighten the height of the Window
. This value includes any and all
decorations which may be added by the Operating System such as the title
bar. Typical applications will set the Scene
height
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 this
Window
is an instance of Stage
, changing this attribute
will not visually affect the Window
while
fullScreen
is true, but will be honored
by the Window
once fullScreen
becomes false.
The property is read only because it can be changed externally by the underlying platform and therefore must not be bindable.
private ReadOnlyBooleanWrapper focused
Window
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.
private static final java.lang.Object USER_DATA_KEY
private ObservableMap<java.lang.Object,java.lang.Object> properties
private Window.SceneModel scene
Scene
to be rendered on this Window
. There can only
be one Scene
on the Window
at a time, and a Scene
can only be on one Window
at a time. Setting a Scene
on
a different Window
will cause the old Window
to lose the
reference before the new one gains it. You may swap Scene
s on
a Window
at any time, even if it is an instance of Stage
and with fullScreen
set to true.
If the width or height of this Window
have never been set by the
application, setting the scene will cause this Window
to take its
width or height from that scene. Resizing this window by end user does
not count as setting the width or height by the application.
An IllegalStateException
is thrown if this property is set
on a thread other than the JavaFX Application Thread.private DoubleProperty opacity
Window
as a value between 0.0 and 1.0.
The opacity is reflected across the Window
, its Decoration
and its Scene
content. On a JavaFX runtime platform that does not
support opacity, assigning a value to this variable will have no
visible difference. A Window
with 0% opacity is fully translucent.
Typically, a Window
with 0% opacity will not receive any mouse
events.private ObjectProperty<EventHandler<WindowEvent>> onCloseRequest
Window
.
The installed event handler can prevent window closing by consuming the
received event.private ObjectProperty<EventHandler<WindowEvent>> onShowing
private ObjectProperty<EventHandler<WindowEvent>> onShown
private ObjectProperty<EventHandler<WindowEvent>> onHiding
private ObjectProperty<EventHandler<WindowEvent>> onHidden
Window
is hidden, this event handler is invoked allowing
the developer to clean up resources or perform other tasks when the
Window
is closed.private ReadOnlyBooleanWrapper showing
Window
is 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.boolean hasBeenVisible
private ObjectProperty<EventDispatcher> eventDispatcher
EventDispatcher
,
the new dispatcher should forward events to the replaced dispatcher
to maintain the node's default event handling behavior.private WindowEventDispatcher internalEventDispatcher
private int focusGrabCounter
private final ReadOnlyObjectWrapper<Screen> screen
@Deprecated public static java.util.Iterator<Window> impl_getWindows()
@Deprecated public TKStage impl_getPeer()
@Deprecated public java.lang.String impl_getMXWindowType()
public void sizeToScene()
private void adjustSize(boolean selfSizePriority)
public void centerOnScreen()
public final void setX(double value)
public final double getX()
public final ReadOnlyDoubleProperty xProperty()
void setXInternal(double value)
public final void setY(double value)
public final double getY()
public final ReadOnlyDoubleProperty yProperty()
void setYInternal(double value)
void notifyLocationChanged(double newX, double newY)
newX
- the new window x positionnewY
- the new window y positionpublic final void setWidth(double value)
public final double getWidth()
public final ReadOnlyDoubleProperty widthProperty()
public final void setHeight(double value)
public final double getHeight()
public final ReadOnlyDoubleProperty heightProperty()
void notifySizeChanged(double newWidth, double newHeight)
newWidth
- the new window widthnewHeight
- the new window height@Deprecated public final void setFocused(boolean value)
public final void requestFocus()
Window
get the input focus.public final boolean isFocused()
public final ReadOnlyBooleanProperty focusedProperty()
public final ObservableMap<java.lang.Object,java.lang.Object> getProperties()
public boolean hasProperties()
public void setUserData(java.lang.Object value)
getUserData()
.value
- The value to be stored - this can later be retrieved by calling
getUserData()
.public java.lang.Object getUserData()
setUserData(java.lang.Object)
method.protected void setScene(Scene value)
public final Scene getScene()
public final ReadOnlyObjectProperty<Scene> sceneProperty()
public final void setOpacity(double value)
public final double getOpacity()
public final DoubleProperty opacityProperty()
public final void setOnCloseRequest(EventHandler<WindowEvent> value)
public final EventHandler<WindowEvent> getOnCloseRequest()
public final ObjectProperty<EventHandler<WindowEvent>> onCloseRequestProperty()
public final void setOnShowing(EventHandler<WindowEvent> value)
public final EventHandler<WindowEvent> getOnShowing()
public final ObjectProperty<EventHandler<WindowEvent>> onShowingProperty()
public final void setOnShown(EventHandler<WindowEvent> value)
public final EventHandler<WindowEvent> getOnShown()
public final ObjectProperty<EventHandler<WindowEvent>> onShownProperty()
public final void setOnHiding(EventHandler<WindowEvent> value)
public final EventHandler<WindowEvent> getOnHiding()
public final ObjectProperty<EventHandler<WindowEvent>> onHidingProperty()
public final void setOnHidden(EventHandler<WindowEvent> value)
public final EventHandler<WindowEvent> getOnHidden()
public final ObjectProperty<EventHandler<WindowEvent>> onHiddenProperty()
private void setShowing(boolean value)
public final boolean isShowing()
public final ReadOnlyBooleanProperty showingProperty()
protected void show()
java.lang.IllegalStateException
- if this method is called on a thread
other than the JavaFX Application Thread.public void hide()
java.lang.IllegalStateException
- if this method is called on a thread
other than the JavaFX Application Thread.@Deprecated protected void impl_visibleChanging(boolean visible)
@Deprecated protected void impl_visibleChanged(boolean visible)
public final void setEventDispatcher(EventDispatcher value)
public final EventDispatcher getEventDispatcher()
public final ObjectProperty<EventDispatcher> eventDispatcherProperty()
public final <T extends Event> void addEventHandler(EventType<T> eventType, EventHandler<? super T> eventHandler)
Event
of the specified type during the bubbling
phase of event delivery.T
- the specific event class of the handlereventType
- the type of the events to receive by the handlereventHandler
- the handler to registerjava.lang.NullPointerException
- if the event type or handler is nullpublic final <T extends Event> void removeEventHandler(EventType<T> eventType, EventHandler<? super T> eventHandler)
T
- the specific event class of the handlereventType
- the event type from which to unregistereventHandler
- the handler to unregisterjava.lang.NullPointerException
- if the event type or handler is nullpublic final <T extends Event> void addEventFilter(EventType<T> eventType, EventHandler<? super T> eventFilter)
Event
of the specified type during the capturing
phase of event delivery.T
- the specific event class of the filtereventType
- the type of the events to receive by the filtereventFilter
- the filter to registerjava.lang.NullPointerException
- if the event type or filter is nullpublic final <T extends Event> void removeEventFilter(EventType<T> eventType, EventHandler<? super T> eventFilter)
T
- the specific event class of the filtereventType
- the event type from which to unregistereventFilter
- the filter to unregisterjava.lang.NullPointerException
- if the event type or filter is nullprotected final <T extends Event> void setEventHandler(EventType<T> eventType, EventHandler<? super T> eventHandler)
T
- the specific event class of the handlereventType
- the event type to associate with the given eventHandlereventHandler
- the handler to register, or null to unregisterjava.lang.NullPointerException
- if the event type is nullWindowEventDispatcher getInternalEventDispatcher()
private void initializeInternalEventDispatcher()
WindowEventDispatcher createInternalEventDispatcher()
public final void fireEvent(Event event)
This method must be called on the FX user thread.
event
- the event to firepublic EventDispatchChain buildEventDispatchChain(EventDispatchChain tail)
buildEventDispatchChain
in interface EventTarget
tail
- the initial chain to build fromvoid increaseFocusGrabCounter()
void decreaseFocusGrabCounter()
private void focusChanged(boolean newIsFocused)
final void applyBounds()
Window getWindowOwner()
private Screen getWindowScreen()
private ReadOnlyObjectProperty<Screen> screenProperty()
private void notifyScreenChanged(java.lang.Object from, java.lang.Object to)