edu.neu.ccs.gui
Class FocusActionAdapter

java.lang.Object
  extended byedu.neu.ccs.gui.FocusActionAdapter
All Implemented Interfaces:
Cloneable, EventListener, FocusListener, Serializable

public class FocusActionAdapter
extends Object
implements FocusListener, Cloneable, Serializable

An adapter class for receiving focus events, and performing actions in response to those events.

Since:
1.0.1
Version:
2.3.3
See Also:
Serialized Form

Field Summary
protected  ActionSequence gainedActions
          List of action listeners to be performed upon the notification of focus gained events.
protected  ActionSequence lostActions
          List of action listeners to be performed upon the notification of focus lost events.
 
Constructor Summary
FocusActionAdapter()
          Constructs a focus action adapter.
FocusActionAdapter(Component target)
          Constructs a focus action adapter listening for focus events generated by the given component.
 
Method Summary
 void addFocusGainedAction(ActionListener a)
          Adds an action listener to this adapter so that it will be performed when the focus is gained.
 void addFocusLostAction(ActionListener a)
          Adds an action listener to this adapter so that it will be performed when the focus is lost.
 void focusGained(FocusEvent evt)
          Performs the stored action sequence when the focus has been gained.
 void focusLost(FocusEvent evt)
          Performs the stored action sequence when the focus has been lost.
 ActionSequence getFocusGainedActions()
          Returns the action sequence for focus gained events.
 ActionSequence getFocusLostActions()
          Returns the action sequence for focus lost events.
 void removeFocusGainedAction(ActionListener a)
          Removes the given action listener from this adapter so that it will be no longer be performed when the focus is gained.
 void removeFocusLostAction(ActionListener a)
          Removes the given action listener from this adapter so that it will be no longer be performed when the focus is lost.
 void setFocusGainedActions(ActionSequence sequence)
          Sets the action sequence for focus gained events to the provided action sequence.
 void setFocusLostActions(ActionSequence sequence)
          Sets the action sequence for focus lost events to the provided action sequence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gainedActions

protected ActionSequence gainedActions
List of action listeners to be performed upon the notification of focus gained events.


lostActions

protected ActionSequence lostActions
List of action listeners to be performed upon the notification of focus lost events.

Constructor Detail

FocusActionAdapter

public FocusActionAdapter()
Constructs a focus action adapter.


FocusActionAdapter

public FocusActionAdapter(Component target)
Constructs a focus action adapter listening for focus events generated by the given component. If null, this adapter does not listen to a particular component by default.

Parameters:
target - the component that is listened to
Method Detail

focusGained

public final void focusGained(FocusEvent evt)
Performs the stored action sequence when the focus has been gained.

Specified by:
focusGained in interface FocusListener
Parameters:
evt - the focus gained event to be handled

focusLost

public final void focusLost(FocusEvent evt)
Performs the stored action sequence when the focus has been lost.

Specified by:
focusLost in interface FocusListener
Parameters:
evt - the focus lost event to be handled

addFocusGainedAction

public void addFocusGainedAction(ActionListener a)
Adds an action listener to this adapter so that it will be performed when the focus is gained.

Parameters:
a - the action listener to be performed
See Also:
removeFocusGainedAction(ActionListener), setFocusGainedActions(ActionSequence), getFocusGainedActions()

addFocusLostAction

public void addFocusLostAction(ActionListener a)
Adds an action listener to this adapter so that it will be performed when the focus is lost.

Parameters:
a - the action listener to be performed
See Also:
removeFocusLostAction(ActionListener), setFocusLostActions(ActionSequence), getFocusLostActions()

removeFocusGainedAction

public void removeFocusGainedAction(ActionListener a)
Removes the given action listener from this adapter so that it will be no longer be performed when the focus is gained.

Parameters:
a - the action listener to be removed
See Also:
addFocusGainedAction(ActionListener), setFocusGainedActions(ActionSequence), getFocusGainedActions()

removeFocusLostAction

public void removeFocusLostAction(ActionListener a)
Removes the given action listener from this adapter so that it will be no longer be performed when the focus is lost.

Parameters:
a - the action listener to be removed
See Also:
addFocusLostAction(ActionListener), setFocusLostActions(ActionSequence), getFocusLostActions()

setFocusGainedActions

public void setFocusGainedActions(ActionSequence sequence)
Sets the action sequence for focus gained events to the provided action sequence. If null, the action sequence for focus gained events is cleared.

Parameters:
sequence - the desired action sequence
See Also:
getFocusGainedActions(), addFocusGainedAction(ActionListener), removeFocusGainedAction(ActionListener)

setFocusLostActions

public void setFocusLostActions(ActionSequence sequence)
Sets the action sequence for focus lost events to the provided action sequence. If null, the action sequence for focus lost events is cleared.

Parameters:
sequence - the desired action sequence
See Also:
getFocusLostActions(), addFocusLostAction(ActionListener), removeFocusLostAction(ActionListener)

getFocusGainedActions

public ActionSequence getFocusGainedActions()
Returns the action sequence for focus gained events.

See Also:
setFocusGainedActions(ActionSequence), addFocusGainedAction(ActionListener), removeFocusGainedAction(ActionListener)

getFocusLostActions

public ActionSequence getFocusLostActions()
Returns the action sequence for focus lost events.

See Also:
setFocusLostActions(ActionSequence), addFocusLostAction(ActionListener), removeFocusLostAction(ActionListener)