de.tkuhn.swing.actions
Class BooleanPreferenceAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by de.tkuhn.swing.actions.DelegatingAction
          extended by de.tkuhn.swing.actions.BooleanPreferenceAction
All Implemented Interfaces:
BooleanAction, ForwardingAction, java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, java.util.prefs.PreferenceChangeListener, javax.swing.Action

public class BooleanPreferenceAction
extends DelegatingAction
implements BooleanAction, java.util.prefs.PreferenceChangeListener

BooleanPreferenceAction is a BooleanAction that is linked together with a boolean Preferences mapping. The state of the action is the reflected of the preference mapping. It also implements the ForwardingAction interface.

Version:
0.9.3
Author:
Tilmann Kuhn
See Also:
BooleanAction, ForwardingAction, Preferences, Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
BooleanPreferenceAction(java.util.prefs.Preferences prefs, java.lang.String key, boolean defaultReturn)
          Creates a new instance of BooleanPreferenceAction
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent actionEvent)
          Implementation of actionPerformed() in ActionListener.
 void destroy()
          If this is not called this object may not be garbage collected since it is registered as a PreferenceChangeListener.
 boolean isSelected()
          Getter for property selected.
 void preferenceChange(java.util.prefs.PreferenceChangeEvent pce)
          Implementation of preferenceChange() in PreferenceChangeListener.
 void setSelected(boolean selected)
          Setter for property selected.
 
Methods inherited from class de.tkuhn.swing.actions.DelegatingAction
addActionListener, removeActionListener
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.Action
addPropertyChangeListener, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 

Constructor Detail

BooleanPreferenceAction

public BooleanPreferenceAction(java.util.prefs.Preferences prefs,
                               java.lang.String key,
                               boolean defaultReturn)
Creates a new instance of BooleanPreferenceAction

Parameters:
prefs - the Preferences holding the boolean mapping
key - the key of the mapping
defaultReturn - the boolean value that should returned if the backing store of the Preferences is not reachable.
Method Detail

preferenceChange

public void preferenceChange(java.util.prefs.PreferenceChangeEvent pce)
Implementation of preferenceChange() in PreferenceChangeListener.

Specified by:
preferenceChange in interface java.util.prefs.PreferenceChangeListener
Parameters:
pce - the PreferenceChangeEvent to be processed.

destroy

public void destroy()
If this is not called this object may not be garbage collected since it is registered as a PreferenceChangeListener.


isSelected

public boolean isSelected()
Getter for property selected.

Specified by:
isSelected in interface BooleanAction
Returns:
Value of property selected.

setSelected

public void setSelected(boolean selected)
Setter for property selected.

Specified by:
setSelected in interface BooleanAction
Parameters:
selected - New value of property selected.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent actionEvent)
Implementation of actionPerformed() in ActionListener.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Overrides:
actionPerformed in class DelegatingAction
Parameters:
actionEvent - the ActionEvent to be processed.


Copyright © Tilmann Kuhn