javax.swing.text
Class TextAction

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.swing.AbstractAction sample code for javax.swing.AbstractAction definition code for javax.swing.AbstractAction 
      extended by javax.swing.text.TextAction
All Implemented Interfaces:
ActionListener sample code for java.awt.event.ActionListener definition code for java.awt.event.ActionListener , Serializable sample code for java.io.Serializable definition code for java.io.Serializable , Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable , EventListener sample code for java.util.EventListener definition code for java.util.EventListener , Action sample code for javax.swing.Action definition code for javax.swing.Action
Direct Known Subclasses:
DefaultEditorKit.BeepAction sample code for javax.swing.text.DefaultEditorKit.BeepAction definition code for javax.swing.text.DefaultEditorKit.BeepAction , DefaultEditorKit.CopyAction sample code for javax.swing.text.DefaultEditorKit.CopyAction definition code for javax.swing.text.DefaultEditorKit.CopyAction , DefaultEditorKit.CutAction sample code for javax.swing.text.DefaultEditorKit.CutAction definition code for javax.swing.text.DefaultEditorKit.CutAction , DefaultEditorKit.DefaultKeyTypedAction sample code for javax.swing.text.DefaultEditorKit.DefaultKeyTypedAction definition code for javax.swing.text.DefaultEditorKit.DefaultKeyTypedAction , DefaultEditorKit.InsertBreakAction sample code for javax.swing.text.DefaultEditorKit.InsertBreakAction definition code for javax.swing.text.DefaultEditorKit.InsertBreakAction , DefaultEditorKit.InsertContentAction sample code for javax.swing.text.DefaultEditorKit.InsertContentAction definition code for javax.swing.text.DefaultEditorKit.InsertContentAction , DefaultEditorKit.InsertTabAction sample code for javax.swing.text.DefaultEditorKit.InsertTabAction definition code for javax.swing.text.DefaultEditorKit.InsertTabAction , DefaultEditorKit.PasteAction sample code for javax.swing.text.DefaultEditorKit.PasteAction definition code for javax.swing.text.DefaultEditorKit.PasteAction , StyledEditorKit.StyledTextAction sample code for javax.swing.text.StyledEditorKit.StyledTextAction definition code for javax.swing.text.StyledEditorKit.StyledTextAction

public abstract class TextAction
extends AbstractAction sample code for javax.swing.AbstractAction definition code for javax.swing.AbstractAction

An Action implementation useful for key bindings that are shared across a number of different text components. Because the action is shared, it must have a way of getting it's target to act upon. This class provides support to try and find a text component to operate on. The preferred way of getting the component to act upon is through the ActionEvent that is received. If the Object returned by getSource can be narrowed to a text component, it will be used. If the action event is null or can't be narrowed, the last focused text component is tried. This is determined by being used in conjunction with a JTextController which arranges to share that information with a TextAction.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see XMLEncoder sample code for java.beans.XMLEncoder definition code for java.beans.XMLEncoder .

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractAction sample code for javax.swing.AbstractAction definition code for javax.swing.AbstractAction
changeSupport sample code for javax.swing.AbstractAction.changeSupport definition code for javax.swing.AbstractAction.changeSupport , enabled sample code for javax.swing.AbstractAction.enabled definition code for javax.swing.AbstractAction.enabled
 
Fields inherited from interface javax.swing.Action sample code for javax.swing.Action definition code for javax.swing.Action
ACCELERATOR_KEY sample code for javax.swing.Action.ACCELERATOR_KEY definition code for javax.swing.Action.ACCELERATOR_KEY , ACTION_COMMAND_KEY sample code for javax.swing.Action.ACTION_COMMAND_KEY definition code for javax.swing.Action.ACTION_COMMAND_KEY , DEFAULT sample code for javax.swing.Action.DEFAULT definition code for javax.swing.Action.DEFAULT , LONG_DESCRIPTION sample code for javax.swing.Action.LONG_DESCRIPTION definition code for javax.swing.Action.LONG_DESCRIPTION , MNEMONIC_KEY sample code for javax.swing.Action.MNEMONIC_KEY definition code for javax.swing.Action.MNEMONIC_KEY , NAME sample code for javax.swing.Action.NAME definition code for javax.swing.Action.NAME , SHORT_DESCRIPTION sample code for javax.swing.Action.SHORT_DESCRIPTION definition code for javax.swing.Action.SHORT_DESCRIPTION , SMALL_ICON sample code for javax.swing.Action.SMALL_ICON definition code for javax.swing.Action.SMALL_ICON
 
Constructor Summary
TextAction sample code for javax.swing.text.TextAction.TextAction(java.lang.String) definition code for javax.swing.text.TextAction.TextAction(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  name)
          Creates a new JTextAction object.
 
Method Summary
static Action sample code for javax.swing.Action definition code for javax.swing.Action [] augmentList sample code for javax.swing.text.TextAction.augmentList(javax.swing.Action[], javax.swing.Action[]) definition code for javax.swing.text.TextAction.augmentList(javax.swing.Action[], javax.swing.Action[]) (Action sample code for javax.swing.Action definition code for javax.swing.Action [] list1, Action sample code for javax.swing.Action definition code for javax.swing.Action [] list2)
          Takes one list of commands and augments it with another list of commands.
protected  JTextComponent sample code for javax.swing.text.JTextComponent definition code for javax.swing.text.JTextComponent getFocusedComponent sample code for javax.swing.text.TextAction.getFocusedComponent() definition code for javax.swing.text.TextAction.getFocusedComponent() ()
          Fetches the text component that currently has focus.
protected  JTextComponent sample code for javax.swing.text.JTextComponent definition code for javax.swing.text.JTextComponent getTextComponent sample code for javax.swing.text.TextAction.getTextComponent(java.awt.event.ActionEvent) definition code for javax.swing.text.TextAction.getTextComponent(java.awt.event.ActionEvent) (ActionEvent sample code for java.awt.event.ActionEvent definition code for java.awt.event.ActionEvent  e)
          Determines the component to use for the action.
 
Methods inherited from class javax.swing.AbstractAction sample code for javax.swing.AbstractAction definition code for javax.swing.AbstractAction
addPropertyChangeListener sample code for javax.swing.AbstractAction.addPropertyChangeListener(java.beans.PropertyChangeListener) definition code for javax.swing.AbstractAction.addPropertyChangeListener(java.beans.PropertyChangeListener) , clone sample code for javax.swing.AbstractAction.clone() definition code for javax.swing.AbstractAction.clone() , firePropertyChange sample code for javax.swing.AbstractAction.firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object) definition code for javax.swing.AbstractAction.firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object) , getKeys sample code for javax.swing.AbstractAction.getKeys() definition code for javax.swing.AbstractAction.getKeys() , getPropertyChangeListeners sample code for javax.swing.AbstractAction.getPropertyChangeListeners() definition code for javax.swing.AbstractAction.getPropertyChangeListeners() , getValue sample code for javax.swing.AbstractAction.getValue(java.lang.String) definition code for javax.swing.AbstractAction.getValue(java.lang.String) , isEnabled sample code for javax.swing.AbstractAction.isEnabled() definition code for javax.swing.AbstractAction.isEnabled() , putValue sample code for javax.swing.AbstractAction.putValue(java.lang.String, java.lang.Object) definition code for javax.swing.AbstractAction.putValue(java.lang.String, java.lang.Object) , removePropertyChangeListener sample code for javax.swing.AbstractAction.removePropertyChangeListener(java.beans.PropertyChangeListener) definition code for javax.swing.AbstractAction.removePropertyChangeListener(java.beans.PropertyChangeListener) , setEnabled sample code for javax.swing.AbstractAction.setEnabled(boolean) definition code for javax.swing.AbstractAction.setEnabled(boolean)
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 
Methods inherited from interface java.awt.event.ActionListener sample code for java.awt.event.ActionListener definition code for java.awt.event.ActionListener
actionPerformed sample code for java.awt.event.ActionListener.actionPerformed(java.awt.event.ActionEvent) definition code for java.awt.event.ActionListener.actionPerformed(java.awt.event.ActionEvent)
 

Constructor Detail

TextAction sample code for javax.swing.text.TextAction(java.lang.String) definition code for javax.swing.text.TextAction(java.lang.String)

public TextAction(String sample code for java.lang.String definition code for java.lang.String  name)
Creates a new JTextAction object.

Parameters:
name - the name of the action
Method Detail

getTextComponent sample code for javax.swing.text.TextAction.getTextComponent(java.awt.event.ActionEvent) definition code for javax.swing.text.TextAction.getTextComponent(java.awt.event.ActionEvent)

protected final JTextComponent sample code for javax.swing.text.JTextComponent definition code for javax.swing.text.JTextComponent  getTextComponent(ActionEvent sample code for java.awt.event.ActionEvent definition code for java.awt.event.ActionEvent  e)
Determines the component to use for the action. This if fetched from the source of the ActionEvent if it's not null and can be narrowed. Otherwise, the last focused component is used.

Parameters:
e - the ActionEvent
Returns:
the component

augmentList sample code for javax.swing.text.TextAction.augmentList(javax.swing.Action[], javax.swing.Action[]) definition code for javax.swing.text.TextAction.augmentList(javax.swing.Action[], javax.swing.Action[])

public static final Action sample code for javax.swing.Action definition code for javax.swing.Action [] augmentList(Action sample code for javax.swing.Action definition code for javax.swing.Action [] list1,
                                         Action sample code for javax.swing.Action definition code for javax.swing.Action [] list2)
Takes one list of commands and augments it with another list of commands. The second list takes precedence over the first list; that is, when both lists contain a command with the same name, the command from the second list is used.

Parameters:
list1 - the first list, may be empty but not null
list2 - the second list, may be empty but not null
Returns:
the augmented list

getFocusedComponent sample code for javax.swing.text.TextAction.getFocusedComponent() definition code for javax.swing.text.TextAction.getFocusedComponent()

protected final JTextComponent sample code for javax.swing.text.JTextComponent definition code for javax.swing.text.JTextComponent  getFocusedComponent()
Fetches the text component that currently has focus. This allows actions to be shared across text components which is useful for key-bindings where a large set of actions are defined, but generally used the same way across many different components.

Returns:
the component