@ThreadSafe public class InputState extends Object
Keeps track of a given input state. Includes mouse/pointer position and keyboard modifier key state.
Synchronization assumes that any given instance might be called from more than one event dispatch thread (EDT.)
| Constructor and Description |
|---|
InputState(Toolkit toolkit) |
| Modifier and Type | Method and Description |
|---|---|
int |
buttons() |
static Component |
childAt(Component parent,
Point where)
Returns the AWT or Swing
Component under the given coordinates in the given parent component. |
void |
clear() |
int |
clickCount() |
Component |
deepestComponentUnderMousePointer() |
void |
dispose() |
boolean |
dragInProgress()
Indicates there is a drag operation in progress.
|
Point |
dragOrigin() |
Component |
dragSource() |
boolean |
isNativeDragActive()
Indicates whether there is a native drag/drop operation in progress.
|
int |
keyModifiers() |
long |
lastEventTime() |
int |
modifiers() |
Component |
mouseComponent()
Returns the last known AWT or Swing
Component to contain the pointer, or null if none. |
Point |
mouseLocation() |
Point |
mouseLocationOnScreen() |
void |
update(AWTEvent event)
Explicitly update the internal state.
|
public void clear()
public void dispose()
public void update(@Nonnull AWTEvent event)
event - the event to use to update the internal state.@Nullable public Component deepestComponentUnderMousePointer()
Component which currently contains the pointer.@Nullable public Component mouseComponent()
Component to contain the pointer, or null if none. Note that
this may not correspond to the Component that actually shows up in AWTEvents.Component to contain the pointer, or null if none.public static Component childAt(@Nonnull Component parent, @Nonnull Point where)
Returns the AWT or Swing Component under the given coordinates in the given parent component. Events are
often generated only for the outermost Container, so we have to determine if the pointer is actually within
a child. Basically the same as Component.getComponentAt, but recurses to the lowest-level Component
instead of only one level. Point is in Component coordinates.
The default Component.getComponentAt can return invisible Components (JRootPane has an
invisible JPanel (glass pane?) which will otherwise swallow everything).
NOTE: childAt grabs the TreeLock, so this should *only* be invoked on the event dispatch thread, preferably
with no other locks held. Use it elsewhere at your own risk.
parent - the given parent.where - the given coordinates.Component under the given coordinates in the given parent Component.public boolean dragInProgress()
true if there is a drag operation in progress, false otherwise.public Component dragSource()
Component where a drag operation started.public Point dragOrigin()
public int clickCount()
public long lastEventTime()
public int modifiers()
public int keyModifiers()
public int buttons()
@Nullable public Point mouseLocation()
null if
outside all components.@Nullable public Point mouseLocationOnScreen()
public boolean isNativeDragActive()
true if there is a native drag/drop operation in progress, false otherwise.Copyright © 2014 AssertJ. All rights reserved.