|
Groovy Documentation | |||||||
| FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.wordpress.tipsforjava.swing.InactivityListener
class InactivityListener extends Object
A class that monitors inactivity in an application. It does this by using a Swing Timer and by listening for specified AWT events. When an event is received the Timer is restarted. If no event is received during the specified time interval then the timer will fire and invoke the specified Action. When creating the listener the inactivity interval is specified in minutes. However, once the listener has been created you can reset this value in milliseconds if you need to. Some common event masks have be defined with the class: KEY_EVENTS MOUSE_EVENTS - which includes mouse motion events USER_EVENTS - includes KEY_EVENTS and MOUSE_EVENT (this is the default) The inactivity interval and event mask can be changed at any time, however, they will not become effective until you stop and start the listener.
| Field Summary | |
|---|---|
static long |
KEY_EVENTS
|
static long |
MOUSE_EVENTS
|
static long |
USER_EVENTS
|
private Action |
action
|
private long |
eventMask
|
private int |
interval
|
private Timer |
timer
|
| Constructor Summary | |
InactivityListener(Action action)
|
|
InactivityListener(Action action, int interval)
|
|
InactivityListener(Action action, int minutes, long eventMask)
|
|
| Method Summary | |
|---|---|
void
|
actionPerformed(ActionEvent e)
|
void
|
eventDispatched(AWTEvent e)
|
void
|
setAction(Action action)
|
void
|
setEventMask(long eventMask)
|
void
|
setInterval(int minutes)
|
void
|
setIntervalInMillis(int interval)
|
void
|
start()
|
void
|
stop()
|
| Methods inherited from class Object | |
|---|---|
| wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
| Field Detail |
|---|
public static final long KEY_EVENTS
public static final long MOUSE_EVENTS
public static final long USER_EVENTS
private Action action
private long eventMask
private int interval
private Timer timer
| Constructor Detail |
|---|
public InactivityListener(Action action)
public InactivityListener(Action action, int interval)
public InactivityListener(Action action, int minutes, long eventMask)
| Method Detail |
|---|
public void actionPerformed(ActionEvent e)
public void eventDispatched(AWTEvent e)
public void setAction(Action action)
public void setEventMask(long eventMask)
public void setInterval(int minutes)
public void setIntervalInMillis(int interval)
public void start()
public void stop()
Groovy Documentation