Groovy Documentation

com.wordpress.tipsforjava.swing
[Java] Class InactivityListener

java.lang.Object
  com.wordpress.tipsforjava.swing.InactivityListener
All Implemented Interfaces:
ActionListener, AWTEventListener

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.

Authors:
Rob Camick
Darryl Burke


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

KEY_EVENTS

public static final long KEY_EVENTS


MOUSE_EVENTS

public static final long MOUSE_EVENTS


USER_EVENTS

public static final long USER_EVENTS


action

private Action action


eventMask

private long eventMask


interval

private int interval


timer

private Timer timer


 
Constructor Detail

InactivityListener

public InactivityListener(Action action)


InactivityListener

public InactivityListener(Action action, int interval)


InactivityListener

public InactivityListener(Action action, int minutes, long eventMask)


 
Method Detail

actionPerformed

public void actionPerformed(ActionEvent e)


eventDispatched

public void eventDispatched(AWTEvent e)


setAction

public void setAction(Action action)


setEventMask

public void setEventMask(long eventMask)


setInterval

public void setInterval(int minutes)


setIntervalInMillis

public void setIntervalInMillis(int interval)


start

public void start()


stop

public void stop()


 

Groovy Documentation