public class ActionEvent extends Object
ActionListener
callback is invokedModifier and Type | Class and Description |
---|---|
static class |
ActionEvent.Type
The event type, as declared when the event is created.
|
Constructor and Description |
---|
ActionEvent(Command source,
ActionEvent.Type type,
Component sourceComponent,
int x,
int y)
Creates a new instance of ActionEvent for a command
|
ActionEvent(Command source,
Component sourceComponent,
int x,
int y)
Creates a new instance of ActionEvent for a command
|
ActionEvent(Component dragged,
ActionEvent.Type type,
Component drop,
int x,
int y)
Creates a new instance of ActionEvent for a drop operation
|
ActionEvent(Component dragged,
Component drop,
int x,
int y)
Creates a new instance of ActionEvent for a drop operation
|
ActionEvent(Object source)
Creates a new instance of ActionEvent.
|
ActionEvent(Object source,
ActionEvent.Type type)
Creates a new instance of ActionEvent
|
ActionEvent(Object source,
ActionEvent.Type type,
int keyEvent)
Creates a new instance of ActionEvent.
|
ActionEvent(Object source,
ActionEvent.Type type,
int x,
int y)
Creates a new instance of ActionEvent as a pointer event
|
ActionEvent(Object source,
int keyEvent)
Creates a new instance of ActionEvent
|
ActionEvent(Object source,
int keyEvent,
boolean longClick)
Creates a new instance of ActionEvent
|
ActionEvent(Object source,
int x,
int y)
Creates a new instance of ActionEvent as a generic pointer event.
|
ActionEvent(Object source,
int x,
int y,
boolean longPointer)
Creates a new instance of ActionEvent as a pointer event
|
Modifier and Type | Method and Description |
---|---|
void |
consume()
Consume the event indicating that it was handled thus preventing other action
listeners from handling/receiving the event
|
Component |
getActualComponent()
Identical to
getComponent() except for the fact that a lead component will be returned
if such a lead component is available. |
Command |
getCommand()
If this event was sent as a result of a command action this method returns
that command
|
Component |
getComponent()
Returns the component that generated the event.
|
Component |
getDraggedComponent()
Set in the case of a drop listener, returns the component being dragged
|
Component |
getDropTarget()
Set in the case of a drop listener, returns the component on which the drop occurs
|
ActionEvent.Type |
getEventType()
Returns the type of the given event allowing us to have more generic event handling code and useful
for debugging
|
int |
getKeyEvent()
If this event was triggered by a key press this method will return the
appropriate keycode
|
int |
getProgress()
Returns the numeric progress of native browser loading on Android
|
Object |
getSource()
The element that triggered the action event, useful for decoupling event
handling code
|
int |
getX()
The X position if this is a pointer event otherwise undefined
|
int |
getY()
The Y position if this is a pointer event otherwise undefined
|
boolean |
isConsumed()
Returns true if the event was consumed thus indicating that it was handled.
|
boolean |
isLongEvent()
Returns true for long click or long pointer event
|
boolean |
isPointerPressedDuringDrag()
Only used for pointer dragged events.
|
void |
setPointerPressedDuringDrag(boolean pressed)
Only used for pointer dragged events.
|
public ActionEvent(Object source)
source
- element for the action eventpublic ActionEvent(Object source, ActionEvent.Type type)
source
- element for the action eventtype
- the ActionEvent.Type
of the eventpublic ActionEvent(Object source, ActionEvent.Type type, int x, int y)
source
- element for the pointer eventtype
- the ActionEvent.Type
of the eventx
- (or sometimes width) associated with the eventy
- (or sometimes height)associated with the eventpublic ActionEvent(Command source, ActionEvent.Type type, Component sourceComponent, int x, int y)
source
- element commandtype
- the ActionEvent.Type
of the eventsourceComponent
- the triggering componentx
- the x position of the pointer eventy
- the y position of the pointer eventpublic ActionEvent(Component dragged, ActionEvent.Type type, Component drop, int x, int y)
dragged
- the dragged componenttype
- the ActionEvent.Type
of the eventdrop
- the drop target componentx
- the x position of the pointer eventy
- the y position of the pointer eventpublic ActionEvent(Object source, ActionEvent.Type type, int keyEvent)
source
- element for the action eventtype
- the ActionEvent.Type
of the eventkeyEvent
- the key that triggered the eventpublic ActionEvent(Object source, int keyEvent)
source
- element for the action eventkeyEvent
- the key that triggered the eventpublic ActionEvent(Object source, int keyEvent, boolean longClick)
source
- element for the action eventkeyEvent
- the key that triggered the eventlongClick
- true if the event is triggered from long pressedpublic ActionEvent(Object source, int x, int y, boolean longPointer)
source
- element for the pointer eventx
- the x position of the pointer eventy
- the y position of the pointer eventlongPointer
- true if the event is triggered from long pressedpublic ActionEvent(Object source, int x, int y)
source
- element for the pointer eventx
- the x position of the pointer eventy
- the y position of the pointer eventpublic ActionEvent(Command source, Component sourceComponent, int x, int y)
source
- element commandsourceComponent
- the triggering componentx
- the x position of the pointer eventy
- the y position of the pointer eventpublic ActionEvent.Type getEventType()
public Object getSource()
public int getKeyEvent()
public int getProgress()
public Command getCommand()
public Component getActualComponent()
getComponent()
except for the fact that a lead component will be returned
if such a lead component is available. This is important for components such as MultiButton
which will return the underlying button instead.public Component getComponent()
Returns the component that generated the event. important this might not be the actual component.
In case of a lead component such as MultiButton
the underlying
Button
will be returned and not the MultiButton
itself. To get the component that you would logically think of as the source component use the getActualComponent()
method.
If you are in doubt use the getActualComponent
method.
- you should probably use {@code getActualComponent} instead of this method
public void consume()
public boolean isConsumed()
public int getX()
public int getY()
public boolean isLongEvent()
public Component getDraggedComponent()
public Component getDropTarget()
public boolean isPointerPressedDuringDrag()
public void setPointerPressedDuringDrag(boolean pressed)