Spec-Zone .ru
спецификации, руководства, описания, API
|
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
or for mobile deployments.
Type | Property and Description |
---|---|
ObjectProperty<EventDispatcher> |
eventDispatcher
Specifies the event dispatcher for this node.
|
ReadOnlyBooleanProperty |
focused
Whether or not this
Window has the keyboard or input focus. |
ReadOnlyDoubleProperty |
height
The height of this
Stage . |
ObjectProperty<EventHandler<WindowEvent>> |
onCloseRequest
Called when there is an external request to close this
Window . |
ObjectProperty<EventHandler<WindowEvent>> |
onHidden
Called just after the Window has been hidden.
|
ObjectProperty<EventHandler<WindowEvent>> |
onHiding
Called just prior to the Window being hidden.
|
ObjectProperty<EventHandler<WindowEvent>> |
onShowing
Called just prior to the Window being shown, even if the menu has
no items to show.
|
ObjectProperty<EventHandler<WindowEvent>> |
onShown
Called just after the Window is shown.
|
DoubleProperty |
opacity
Defines the opacity of the
Stage as a value between 0.0 and 1.0. |
ReadOnlyObjectProperty<Scene> |
scene
The
Scene to be rendered on this Stage . |
ReadOnlyBooleanProperty |
showing
Whether or not this
Stage is showing (that is, open on the
user's system). |
ReadOnlyDoubleProperty |
width
The width of this
Stage . |
ReadOnlyDoubleProperty |
x
The horizontal location of this
Stage on the screen. |
ReadOnlyDoubleProperty |
y
The vertical location of this
Stage on the screen. |
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.
|
EventDispatchChain |
buildEventDispatchChain(EventDispatchChain tail)
Construct an event dispatch chain for this stage.
|
void |
centerOnScreen()
Sets x and y properties on this Window so that it is centered on the screen.
|
ObjectProperty<EventDispatcher> |
eventDispatcherProperty()
Specifies the event dispatcher for this node.
|
void |
fireEvent(Event event)
Fires the specified event.
|
ReadOnlyBooleanProperty |
focusedProperty()
Whether or not this
Window has the keyboard or input focus. |
EventDispatcher |
getEventDispatcher()
Specifies the event dispatcher for this node.
|
double |
getHeight()
The height of this
Stage . |
EventHandler<WindowEvent> |
getOnCloseRequest()
Called when there is an external request to close this
Window . |
EventHandler<WindowEvent> |
getOnHidden()
Called just after the Window has been hidden.
|
EventHandler<WindowEvent> |
getOnHiding()
Called just prior to the Window being hidden.
|
EventHandler<WindowEvent> |
getOnShowing()
Called just prior to the Window being shown, even if the menu has
no items to show.
|
EventHandler<WindowEvent> |
getOnShown()
Called just after the Window is shown.
|
double |
getOpacity()
Defines the opacity of the
Stage as a value between 0.0 and 1.0. |
Scene |
getScene()
The
Scene to be rendered on this Stage . |
double |
getWidth()
The width of this
Stage . |
double |
getX()
The horizontal location of this
Stage on the screen. |
double |
getY()
The vertical location of this
Stage on the screen. |
ReadOnlyDoubleProperty |
heightProperty()
The height of this
Stage . |
void |
hide()
Attempts to hide this Window by setting the visibility to false.
|
boolean |
isFocused()
Whether or not this
Window has the keyboard or input focus. |
boolean |
isShowing()
Whether or not this
Stage is showing (that is, open on the
user's system). |
ObjectProperty<EventHandler<WindowEvent>> |
onCloseRequestProperty()
Called when there is an external request to close this
Window . |
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, even if the menu has
no items to show.
|
ObjectProperty<EventHandler<WindowEvent>> |
onShownProperty()
Called just after the Window is shown.
|
DoubleProperty |
opacityProperty()
Defines the opacity of the
Stage as a value between 0.0 and 1.0. |
<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()
The
Scene to be rendered on this Stage . |
void |
setEventDispatcher(EventDispatcher value)
Specifies the event dispatcher for this node.
|
protected <T extends Event> |
setEventHandler(EventType<T> eventType,
EventHandler<? super T> eventHandler)
Sets the handler to use for this event type.
|
void |
setHeight(double value)
The height of this
Stage . |
void |
setOnCloseRequest(EventHandler<WindowEvent> value)
Called when there is an external request to close this
Window . |
void |
setOnHidden(EventHandler<WindowEvent> value)
Called just after the Window has been hidden.
|
void |
setOnHiding(EventHandler<WindowEvent> value)
Called just prior to the Window being hidden.
|
void |
setOnShowing(EventHandler<WindowEvent> value)
Called just prior to the Window being shown, even if the menu has
no items to show.
|
void |
setOnShown(EventHandler<WindowEvent> value)
Called just after the Window is shown.
|
void |
setOpacity(double value)
Defines the opacity of the
Stage as a value between 0.0 and 1.0. |
protected void |
setScene(Scene value)
The
Scene to be rendered on this Stage . |
void |
setWidth(double value)
The width of this
Stage . |
void |
setX(double value)
The horizontal location of this
Stage on the screen. |
void |
setY(double value)
The vertical location of this
Stage on the screen. |
protected void |
show()
Attempts to show this Window by setting visibility to true
|
ReadOnlyBooleanProperty |
showingProperty()
Whether or not this
Stage is showing (that is, open on the
user's system). |
void |
sizeToScene()
Set the width and height of this Window to match the size of the content
of this Window's Scene.
|
ReadOnlyDoubleProperty |
widthProperty()
The width of this
Stage . |
ReadOnlyDoubleProperty |
xProperty()
The horizontal location of this
Stage on the screen. |
ReadOnlyDoubleProperty |
yProperty()
The vertical location of this
Stage on the screen. |
Stage
on the screen. Changing
this attribute will move the Stage
horizontally. Changing this
attribute will not visually affect a Stage
while
fullScreen
is true, but will be honored by the Stage
once
fullScreen
becomes false.getX()
,
setX(double)
Stage
on the screen. Changing this
attribute will move the Stage
vertically. Changing this
attribute will not visually affect a Stage
while
fullScreen
is true, but will be honored by the Stage
once
fullScreen
becomes false.getY()
,
setY(double)
Stage
. Changing this attribute will narrow or
widen the width of the Stage
. Changing this
attribute will not visually affect a Stage
while
fullScreen
is true, but will be honored by the Stage
once
fullScreen
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 the Scene
width
instead.getWidth()
,
setWidth(double)
Stage
. Changing this attribute will shrink
or heighten the height of the Stage
. Changing this
attribute will not visually affect a Stage
while
fullScreen
is true, but will be honored by the Stage
once
fullScreen
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 the Scene
height instead.getHeight()
,
setHeight(double)
Window
has the keyboard or input focus.isFocused()
,
setFocused(boolean)
Scene
to be rendered on this Stage
. There can only
be one Scene
on the Stage
at a time, and a Scene
can only be on one Stage
at a time. Setting a Scene
on
a different Stage
will cause the old Stage
to lose the
reference before the new one gains it. You may swap Scene
s on
a Stage
at any time, even while in full-screen exclusive mode.
An IllegalStateException
is thrown if this property is set
on a thread other than the JavaFX Application Thread.getScene()
,
setScene(Scene)
Stage
as a value between 0.0 and 1.0.
The opacity is reflected across the Stage
, 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 Stage
with 0% opacity is fully translucent.
Typically, a Stage
with 0% opacity will not receive any mouse
events.getOpacity()
,
setOpacity(double)
Window
.
The installed event handler can prevent window closing by consuming the
received event.getOnShowing()
,
setOnShowing(EventHandler)
getOnShown()
,
setOnShown(EventHandler)
getOnHiding()
,
setOnHiding(EventHandler)
Window
is hidden, this event handler is invoked allowing
the developer to clean up resources or perform other tasks when the
Window
is closed.getOnHidden()
,
setOnHidden(EventHandler)
Stage
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.isShowing()
EventDispatcher
,
the new dispatcher should forward events to the replaced dispatcher
to maintain the node's default event handling behavior.public void sizeToScene()
public void centerOnScreen()
public final void setX(double value)
Stage
on the screen. Changing
this attribute will move the Stage
horizontally. Changing this
attribute will not visually affect a Stage
while
fullScreen
is true, but will be honored by the Stage
once
fullScreen
becomes false.public final double getX()
Stage
on the screen. Changing
this attribute will move the Stage
horizontally. Changing this
attribute will not visually affect a Stage
while
fullScreen
is true, but will be honored by the Stage
once
fullScreen
becomes false.public final ReadOnlyDoubleProperty xProperty()
Stage
on the screen. Changing
this attribute will move the Stage
horizontally. Changing this
attribute will not visually affect a Stage
while
fullScreen
is true, but will be honored by the Stage
once
fullScreen
becomes false.getX()
,
setX(double)
public final void setY(double value)
Stage
on the screen. Changing this
attribute will move the Stage
vertically. Changing this
attribute will not visually affect a Stage
while
fullScreen
is true, but will be honored by the Stage
once
fullScreen
becomes false.public final double getY()
Stage
on the screen. Changing this
attribute will move the Stage
vertically. Changing this
attribute will not visually affect a Stage
while
fullScreen
is true, but will be honored by the Stage
once
fullScreen
becomes false.public final ReadOnlyDoubleProperty yProperty()
Stage
on the screen. Changing this
attribute will move the Stage
vertically. Changing this
attribute will not visually affect a Stage
while
fullScreen
is true, but will be honored by the Stage
once
fullScreen
becomes false.getY()
,
setY(double)
public final void setWidth(double value)
Stage
. Changing this attribute will narrow or
widen the width of the Stage
. Changing this
attribute will not visually affect a Stage
while
fullScreen
is true, but will be honored by the Stage
once
fullScreen
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 the Scene
width
instead.public final double getWidth()
Stage
. Changing this attribute will narrow or
widen the width of the Stage
. Changing this
attribute will not visually affect a Stage
while
fullScreen
is true, but will be honored by the Stage
once
fullScreen
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 the Scene
width
instead.public final ReadOnlyDoubleProperty widthProperty()
Stage
. Changing this attribute will narrow or
widen the width of the Stage
. Changing this
attribute will not visually affect a Stage
while
fullScreen
is true, but will be honored by the Stage
once
fullScreen
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 the Scene
width
instead.getWidth()
,
setWidth(double)
public final void setHeight(double value)
Stage
. Changing this attribute will shrink
or heighten the height of the Stage
. Changing this
attribute will not visually affect a Stage
while
fullScreen
is true, but will be honored by the Stage
once
fullScreen
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 the Scene
height instead.public final double getHeight()
Stage
. Changing this attribute will shrink
or heighten the height of the Stage
. Changing this
attribute will not visually affect a Stage
while
fullScreen
is true, but will be honored by the Stage
once
fullScreen
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 the Scene
height instead.public final ReadOnlyDoubleProperty heightProperty()
Stage
. Changing this attribute will shrink
or heighten the height of the Stage
. Changing this
attribute will not visually affect a Stage
while
fullScreen
is true, but will be honored by the Stage
once
fullScreen
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 the Scene
height instead.getHeight()
,
setHeight(double)
public final void requestFocus()
Window
get the input focus.public final boolean isFocused()
Window
has the keyboard or input focus.public final ReadOnlyBooleanProperty focusedProperty()
Window
has the keyboard or input focus.isFocused()
,
setFocused(boolean)
protected void setScene(Scene value)
Scene
to be rendered on this Stage
. There can only
be one Scene
on the Stage
at a time, and a Scene
can only be on one Stage
at a time. Setting a Scene
on
a different Stage
will cause the old Stage
to lose the
reference before the new one gains it. You may swap Scene
s on
a Stage
at any time, even while in full-screen exclusive mode.
An IllegalStateException
is thrown if this property is set
on a thread other than the JavaFX Application Thread.public final Scene getScene()
Scene
to be rendered on this Stage
. There can only
be one Scene
on the Stage
at a time, and a Scene
can only be on one Stage
at a time. Setting a Scene
on
a different Stage
will cause the old Stage
to lose the
reference before the new one gains it. You may swap Scene
s on
a Stage
at any time, even while in full-screen exclusive mode.
An IllegalStateException
is thrown if this property is set
on a thread other than the JavaFX Application Thread.public final ReadOnlyObjectProperty<Scene> sceneProperty()
Scene
to be rendered on this Stage
. There can only
be one Scene
on the Stage
at a time, and a Scene
can only be on one Stage
at a time. Setting a Scene
on
a different Stage
will cause the old Stage
to lose the
reference before the new one gains it. You may swap Scene
s on
a Stage
at any time, even while in full-screen exclusive mode.
An IllegalStateException
is thrown if this property is set
on a thread other than the JavaFX Application Thread.getScene()
,
setScene(Scene)
public final void setOpacity(double value)
Stage
as a value between 0.0 and 1.0.
The opacity is reflected across the Stage
, 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 Stage
with 0% opacity is fully translucent.
Typically, a Stage
with 0% opacity will not receive any mouse
events.public final double getOpacity()
Stage
as a value between 0.0 and 1.0.
The opacity is reflected across the Stage
, 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 Stage
with 0% opacity is fully translucent.
Typically, a Stage
with 0% opacity will not receive any mouse
events.public final DoubleProperty opacityProperty()
Stage
as a value between 0.0 and 1.0.
The opacity is reflected across the Stage
, 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 Stage
with 0% opacity is fully translucent.
Typically, a Stage
with 0% opacity will not receive any mouse
events.getOpacity()
,
setOpacity(double)
public final void setOnCloseRequest(EventHandler<WindowEvent> value)
Window
.
The installed event handler can prevent window closing by consuming the
received event.public final EventHandler<WindowEvent> getOnCloseRequest()
Window
.
The installed event handler can prevent window closing by consuming the
received event.public final ObjectProperty<EventHandler<WindowEvent>> onCloseRequestProperty()
Window
.
The installed event handler can prevent window closing by consuming the
received event.public final void setOnShowing(EventHandler<WindowEvent> value)
public final EventHandler<WindowEvent> getOnShowing()
public final ObjectProperty<EventHandler<WindowEvent>> onShowingProperty()
getOnShowing()
,
setOnShowing(EventHandler)
public final void setOnShown(EventHandler<WindowEvent> value)
public final EventHandler<WindowEvent> getOnShown()
public final ObjectProperty<EventHandler<WindowEvent>> onShownProperty()
getOnShown()
,
setOnShown(EventHandler)
public final void setOnHiding(EventHandler<WindowEvent> value)
public final EventHandler<WindowEvent> getOnHiding()
public final ObjectProperty<EventHandler<WindowEvent>> onHidingProperty()
getOnHiding()
,
setOnHiding(EventHandler)
public final void setOnHidden(EventHandler<WindowEvent> value)
Window
is hidden, this event handler is invoked allowing
the developer to clean up resources or perform other tasks when the
Window
is closed.public final EventHandler<WindowEvent> getOnHidden()
Window
is hidden, this event handler is invoked allowing
the developer to clean up resources or perform other tasks when the
Window
is closed.public final ObjectProperty<EventHandler<WindowEvent>> onHiddenProperty()
Window
is hidden, this event handler is invoked allowing
the developer to clean up resources or perform other tasks when the
Window
is closed.getOnHidden()
,
setOnHidden(EventHandler)
public final boolean isShowing()
Stage
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.public final ReadOnlyBooleanProperty showingProperty()
Stage
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.isShowing()
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.public final void setEventDispatcher(EventDispatcher value)
EventDispatcher
,
the new dispatcher should forward events to the replaced dispatcher
to maintain the node's default event handling behavior.public final EventDispatcher getEventDispatcher()
EventDispatcher
,
the new dispatcher should forward events to the replaced dispatcher
to maintain the node's default event handling behavior.public final ObjectProperty<EventDispatcher> eventDispatcherProperty()
EventDispatcher
,
the new dispatcher should forward events to the replaced dispatcher
to maintain the node's default event handling behavior.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 registerpublic 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 unregisterpublic 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 registerpublic 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 unregisterprotected 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 unregisterpublic 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 fromCopyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. Use is subject to