abbot.tester
Class InputState

java.lang.Object
  extended by abbot.tester.InputState

public class InputState
extends Object

Class to keep 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.

NOTE: Java 1.5 introduces MouseState, which provides current mouse coords


Constructor Summary
InputState()
           
 
Method Summary
 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InputState

public InputState()
Method Detail

clear

public void clear()

dispose

public void dispose()

update

void update(AWTEvent event)
Explicitly update the internal state. Allows Robot to update the state with events it has just posted.


updateState

protected void updateState(KeyEvent ke)

updateState

protected void updateState(MouseEvent me)

getComponentAt

public static Component getComponentAt(Component parent,
                                       Point p)
Return the 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: 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?


getUltimateMouseComponent

public Component getUltimateMouseComponent()
Return the most deeply nested component which currently contains the pointer.


getMouseComponent

public Component getMouseComponent()
Return the last known Component to contain the pointer, or null if none. Note that this may not correspond to the component that actually shows up in AWTEvents.


isDragging

public boolean isDragging()

getDragSource

public Component getDragSource()

setDragSource

public void setDragSource(Component c)

getDragOrigin

public Point getDragOrigin()

getClickCount

public int getClickCount()

setClickCount

protected void setClickCount(int count)

getLastEventTime

public long getLastEventTime()

setLastEventTime

protected void setLastEventTime(long t)

getModifiers

public int getModifiers()
Returns all currently active modifiers.


setModifiers

protected void setModifiers(int m)

getKeyModifiers

public int getKeyModifiers()
Returns the currently pressed key modifiers.


getButtons

public int getButtons()

setButtons

protected void setButtons(int b)

getMouseLocation

public Point getMouseLocation()
Returns the mouse location relative to the component that currently contains the pointer, or null if outside all components.


getMouseLocationOnScreen

public Point getMouseLocationOnScreen()
Returns the last known mouse location.


isNativeDragActive

public boolean isNativeDragActive()
Return whether there is a native drag/drop operation in progress.



Copyright © 2002-2008 Timothy Wall. All Rights Reserved.
Abbot is hosted on

SourceForge