public class InputState extends Object
Synchronization assumes that any given instance might be called from more than one event dispatch thread.
NOTE: Java 1.5 introduces MouseState, which provides current mouse coords
Constructor and Description |
---|
InputState() |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
void |
dispose() |
int |
getButtons() |
int |
getClickCount() |
static Component |
getComponentAt(Component parent,
Point p)
Return the component under the given coordinates in the given parent
component.
|
Point |
getDragOrigin() |
Component |
getDragSource() |
int |
getKeyModifiers()
Returns the currently pressed key modifiers.
|
long |
getLastEventTime() |
int |
getModifiers()
Returns all currently active modifiers.
|
Component |
getMouseComponent()
Return the last known Component to contain the pointer, or null if
none.
|
Point |
getMouseLocation()
Returns the mouse location relative to the component that currently
contains the pointer, or null if outside all components.
|
Point |
getMouseLocationOnScreen()
Returns the last known mouse location.
|
Component |
getUltimateMouseComponent()
Return the most deeply nested component which currently contains the
pointer.
|
boolean |
isDragging() |
boolean |
isNativeDragActive()
Return whether there is a native drag/drop operation in progress.
|
protected void |
setButtons(int b) |
protected void |
setClickCount(int count) |
void |
setDragSource(Component c) |
protected void |
setLastEventTime(long t) |
protected void |
setModifiers(int m) |
(package private) void |
update(AWTEvent event)
Explicitly update the internal state.
|
protected void |
updateState(KeyEvent ke) |
protected void |
updateState(MouseEvent me) |
public void clear()
public void dispose()
void update(AWTEvent event)
protected void updateState(KeyEvent ke)
protected void updateState(MouseEvent me)
public static Component getComponentAt(Component parent, Point p)
The default Component.getComponentAt can return invisible components (JRootPane has an invisible JPanel (glass pane?) which will otherwise swallow everything).
NOTE: getComponentAt 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.
NOTE: What about drags outside a component?
public Component getUltimateMouseComponent()
public Component getMouseComponent()
public boolean isDragging()
public Component getDragSource()
public void setDragSource(Component c)
public Point getDragOrigin()
public int getClickCount()
protected void setClickCount(int count)
public long getLastEventTime()
protected void setLastEventTime(long t)
public int getModifiers()
protected void setModifiers(int m)
public int getKeyModifiers()
public int getButtons()
protected void setButtons(int b)
public Point getMouseLocation()
public Point getMouseLocationOnScreen()
public boolean isNativeDragActive()
Abbot is hosted on