Module javafx.graphics
Package javafx.stage

# Class WindowEvent

java.lang.Object
java.util.EventObject
javafx.event.Event
javafx.stage.WindowEvent

All Implemented Interfaces:
  `Serializable`, `Cloneable`

public class WindowEvent extends Event
Event related to window showing/hiding actions.

Since:
  JavaFX 2.0
See Also:
  - Serialized Form

## Field Summary

Fields
Modifier and Type
Field
Description
`static final EventType<WindowEvent>`
`ANY`
Common supertype for all window event types.
`static final EventType<WindowEvent>`
`WINDOW_CLOSE_REQUEST`
This event is delivered to a window when there is an external request to close that window.
`static final EventType<WindowEvent>`
`WINDOW_HIDDEN`
This event occurs on window just after it is hidden.
`static final EventType<WindowEvent>`
`WINDOW_HIDING`
This event occurs on window just before it is hidden.
`static final EventType<WindowEvent>`
`WINDOW_SHOWING`
This event occurs on window just before it is shown.
`static final EventType<WindowEvent>`
`WINDOW_SHOWN`
This event occurs on window just after it is shown.

### Fields inherited from class javafx.event.Event

`consumed, eventType, NULL_SOURCE_TARGET, target`

### Fields inherited from class java.util.EventObject

`source`

## Constructor Summary

Constructors
Constructor
Description
`WindowEvent(Window source, EventType<? extends Event> eventType)`
Construct a new `Event` with the specified event source, target and type.

## Method Summary

Modifier and Type
Method
Description
`WindowEvent`
`copyFor(Object newSource, EventTarget newTarget)`
Creates and returns a copy of this event with the specified event source and target.
`WindowEvent`
`copyFor(Object newSource, EventTarget newTarget, EventType<WindowEvent> type)`
Creates a copy of the given event with the given fields substituted.
`EventType<WindowEvent>`
`getEventType()`
Gets the event type of this event.
`String`
`toString()`
Returns a string representation of this `WindowEvent` object.

### Methods inherited from class javafx.event.Event

`clone, consume, fireEvent, getTarget, isConsumed`

### Methods inherited from class java.util.EventObject

`getSource`

### Methods inherited from class java.lang.Object

`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### ANY

public static final EventType<WindowEvent> ANY
Common supertype for all window event types.

### WINDOW_SHOWING

public static final EventType<WindowEvent> WINDOW_SHOWING
This event occurs on window just before it is shown.

### WINDOW_SHOWN

public static final EventType<WindowEvent> WINDOW_SHOWN
This event occurs on window just after it is shown.

### WINDOW_HIDING

public static final EventType<WindowEvent> WINDOW_HIDING
This event occurs on window just before it is hidden.

### WINDOW_HIDDEN

public static final EventType<WindowEvent> WINDOW_HIDDEN
This event occurs on window just after it is hidden.

### WINDOW_CLOSE_REQUEST

public static final EventType<WindowEvent> WINDOW_CLOSE_REQUEST
This event is delivered to a window when there is an external request to close that window. If the event is not consumed by any installed window event handler, the default handler for this event closes the corresponding window.

## Constructor Details

### WindowEvent

public WindowEvent(Window source, EventType<? extends Event> eventType)
Construct a new `Event` with the specified event source, target and type. If the source or target is set to `null`, it is replaced by the `NULL_SOURCE_TARGET` value.

Parameters:
  `source` - the event source which sent the event
  `eventType` - the event type

## Method Details

### toString

public String toString()
Returns a string representation of this `WindowEvent` object.

Overrides:
  `toString` in class `EventObject`
Returns:
  a string representation of this `WindowEvent` object.

### copyFor

public WindowEvent copyFor(Object newSource, EventTarget newTarget)
Description copied from class: `Event`
Creates and returns a copy of this event with the specified event source and target. If the source or target is set to `null`, it is replaced by the `NULL_SOURCE_TARGET` value.

Overrides:
  `copyFor` in class `Event`
Parameters:
  `newSource` - the new source of the copied event
  `newTarget` - the new target of the copied event
Returns:
  the event copy with the new source and target

### copyFor

public WindowEvent copyFor(Object newSource, EventTarget newTarget, EventType<WindowEvent> type)
Creates a copy of the given event with the given fields substituted.

Parameters:
  `newSource` - the new source of the copied event
  `newTarget` - the new target of the copied event
  `type` - the new eventType
Returns:
  the event copy with the fields substituted
Since:
  JavaFX 8.0

### getEventType

public EventType<WindowEvent> getEventType()
Description copied from class: `Event`
Gets the event type of this event. Objects of the same `Event` class can have different event types. These event types further specify what kind of event occurred.

Overrides:
  `getEventType` in class `Event`
Returns:
  the event type