Top Description Fields Constructors Methods
javafx.scene.input

public final Class SwipeEvent

extends GestureEvent
Class Inheritance
Imports
javafx.beans.NamedArg, javafx.event.EventTarget, .EventType

Swipe event indicates that user performed a swipe gesture such as dragging a finger in one direction on touch screen.

Unlike some other gestures, the swipe gesture is not continual - the whole gesture produces only one event. The event is delivered to the top-most node picked on the gesture coordinates.

The swipe gesture has four types according to the movement direction. The gesture can be performed by any number of touch points, the number is provided by getTouchCount() method.

Note that swipe and scroll gestures are not exclusive. A single touch screen action can result in both gestures being delivered.

Note that the capability to produce swipes is dependent on the used input devices and underlying platform's capabilities and settings (especially without touch-screen user's possibilities of producing swipes are significantly reduced).

As all gestures, swipe can be direct (performed directly at the concrete coordinates as on touch screen - the center of the gesture is used as gesture coordinates) or indirect (performed indirectly as on track pad - the mouse cursor location is usually used as the gesture coordinates in this case).

Since
JavaFX 2.2

Field Summary

Modifier and TypeField and Description
public static final EventType<SwipeEvent>
ANY

Hides javafx.scene.input.GestureEvent.ANY.

Common supertype for all swipe event types.
private static final long
public static final EventType<SwipeEvent>
SWIPE_DOWN

This event occurs when user performs downward swipe gesture.

public static final EventType<SwipeEvent>
SWIPE_LEFT

This event occurs when user performs leftward swipe gesture.

public static final EventType<SwipeEvent>
SWIPE_RIGHT

This event occurs when user performs rightward swipe gesture.

public static final EventType<SwipeEvent>
SWIPE_UP

This event occurs when user performs upward swipe gesture.

private final int

Constructor Summary

AccessConstructor and Description
public
SwipeEvent(Object
the source of the event. Can be null.
source
,
EventTarget
the target of the event. Can be null.
target
,
final EventType<SwipeEvent>
The type of the event.
eventType
,
double
The x with respect to the scene.
x
,
double
The y with respect to the scene.
y
,
double
The x coordinate relative to screen.
screenX
,
double
The y coordinate relative to screen.
screenY
,
boolean
true if shift modifier was pressed.
shiftDown
,
boolean
true if control modifier was pressed.
controlDown
,
boolean
true if alt modifier was pressed.
altDown
,
boolean
true if meta modifier was pressed.
metaDown
,
boolean
true if the event was caused by direct input device. See isDirect()
direct
,
int
number of touch points
touchCount
,
PickResult
pick result. Can be null, in this case a 2D pick result without any further values is constructed based on the scene coordinates and the target
pickResult
)

Constructs new SwipeEvent event.

public
SwipeEvent(final EventType<SwipeEvent>
The type of the event.
eventType
,
double
The x with respect to the scene.
x
,
double
The y with respect to the scene.
y
,
double
The x coordinate relative to screen.
screenX
,
double
The y coordinate relative to screen.
screenY
,
boolean
true if shift modifier was pressed.
shiftDown
,
boolean
true if control modifier was pressed.
controlDown
,
boolean
true if alt modifier was pressed.
altDown
,
boolean
true if meta modifier was pressed.
metaDown
,
boolean
true if the event was caused by direct input device. See isDirect()
direct
,
int
number of touch points
touchCount
,
PickResult
pick result. Can be null, in this case a 2D pick result without any further values is constructed based on the scene coordinates
pickResult
)

Constructs new SwipeEvent event with null source and target.

Method Summary

Modifier and TypeMethod and Description
public SwipeEvent
copyFor(Object
the new source of the copied event
newSource
,
EventTarget
the new target of the copied event
newTarget
)

Overrides javafx.scene.input.GestureEvent.copyFor.

Creates and returns a copy of this event with the specified event source and target.

public SwipeEvent

Returns:

the event copy with the fields substituted
copyFor
(Object
the new source of the copied event
newSource
,
EventTarget
the new target of the copied event
newTarget
,
EventType<SwipeEvent>
the new eventType
type
)

Creates a copy of the given event with the given fields substituted.

public EventType<SwipeEvent>
getEventType()

Overrides javafx.scene.input.GestureEvent.getEventType.

Gets the event type of this event.

public int

Returns:

Number of touch points that caused this event
getTouchCount
()

Gets number of touch points that caused this event.

public String

Returns:

a string representation of this SwipeEvent object.
toString
()

Overrides javafx.scene.input.GestureEvent.toString.

Returns a string representation of this SwipeEvent object.

Inherited from javafx.scene.input.GestureEvent:
getPickResultgetSceneXgetSceneYgetScreenXgetScreenYgetXgetYgetZisAltDownisControlDownisDirectisInertiaisMetaDownisShiftDownisShortcutDown

Field Detail

ANYback to summary
public static final EventType<SwipeEvent> ANY

Hides javafx.scene.input.GestureEvent.ANY.

Common supertype for all swipe event types.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides javafx.scene.input.GestureEvent.serialVersionUID.

SWIPE_DOWNback to summary
public static final EventType<SwipeEvent> SWIPE_DOWN

This event occurs when user performs downward swipe gesture.

SWIPE_LEFTback to summary
public static final EventType<SwipeEvent> SWIPE_LEFT

This event occurs when user performs leftward swipe gesture.

SWIPE_RIGHTback to summary
public static final EventType<SwipeEvent> SWIPE_RIGHT

This event occurs when user performs rightward swipe gesture.

SWIPE_UPback to summary
public static final EventType<SwipeEvent> SWIPE_UP

This event occurs when user performs upward swipe gesture.

touchCountback to summary
private final int touchCount
Annotations
@SuppressWarnings:doclint:missing

Constructor Detail

SwipeEventback to summary
public SwipeEvent(Object source, EventTarget target, final EventType<SwipeEvent> eventType, double x, double y, double screenX, double screenY, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean direct, int touchCount, PickResult pickResult)

Constructs new SwipeEvent event.

Parameters
source:Object

the source of the event. Can be null.

target:EventTarget

the target of the event. Can be null.

eventType:EventType<SwipeEvent>

The type of the event.

x:double

The x with respect to the scene.

y:double

The y with respect to the scene.

screenX:double

The x coordinate relative to screen.

screenY:double

The y coordinate relative to screen.

shiftDown:boolean

true if shift modifier was pressed.

controlDown:boolean

true if control modifier was pressed.

altDown:boolean

true if alt modifier was pressed.

metaDown:boolean

true if meta modifier was pressed.

direct:boolean

true if the event was caused by direct input device. See isDirect()

touchCount:int

number of touch points

pickResult:PickResult

pick result. Can be null, in this case a 2D pick result without any further values is constructed based on the scene coordinates and the target

Since
JavaFX 8.0
SwipeEventback to summary
public SwipeEvent(final EventType<SwipeEvent> eventType, double x, double y, double screenX, double screenY, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean direct, int touchCount, PickResult pickResult)

Constructs new SwipeEvent event with null source and target.

Parameters
eventType:EventType<SwipeEvent>

The type of the event.

x:double

The x with respect to the scene.

y:double

The y with respect to the scene.

screenX:double

The x coordinate relative to screen.

screenY:double

The y coordinate relative to screen.

shiftDown:boolean

true if shift modifier was pressed.

controlDown:boolean

true if control modifier was pressed.

altDown:boolean

true if alt modifier was pressed.

metaDown:boolean

true if meta modifier was pressed.

direct:boolean

true if the event was caused by direct input device. See isDirect()

touchCount:int

number of touch points

pickResult:PickResult

pick result. Can be null, in this case a 2D pick result without any further values is constructed based on the scene coordinates

Since
JavaFX 8.0

Method Detail

copyForback to summary
public SwipeEvent copyFor(Object newSource, EventTarget newTarget)

Overrides javafx.scene.input.GestureEvent.copyFor.

Doc from javafx.scene.input.GestureEvent.copyFor.

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.

Parameters
newSource:Object

Doc from javafx.event.Event.copyFor.

the new source of the copied event

newTarget:EventTarget

Doc from javafx.event.Event.copyFor.

the new target of the copied event

Returns:SwipeEvent

Doc from javafx.event.Event.copyFor.

the event copy with the new source and target

Annotations
@Override
copyForback to summary
public SwipeEvent copyFor(Object newSource, EventTarget newTarget, EventType<SwipeEvent> type)

Creates a copy of the given event with the given fields substituted.

Parameters
newSource:Object

the new source of the copied event

newTarget:EventTarget

the new target of the copied event

type:EventType<SwipeEvent>

the new eventType

Returns:SwipeEvent

the event copy with the fields substituted

Since
JavaFX 8.0
getEventTypeback to summary
public EventType<SwipeEvent> getEventType()

Overrides javafx.scene.input.GestureEvent.getEventType.

Doc from javafx.event.Event.getEventType.

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.

Returns:EventType<SwipeEvent>

the event type

Annotations
@Override
getTouchCountback to summary
public int getTouchCount()

Gets number of touch points that caused this event.

Returns:int

Number of touch points that caused this event

toStringback to summary
public String toString()

Overrides javafx.scene.input.GestureEvent.toString.

Returns a string representation of this SwipeEvent object.

Returns:String

a string representation of this SwipeEvent object.

Annotations
@Override