/[classpath]/classpath/javax/swing/text/TextAction.java
ViewVC logotype

Diff of /classpath/javax/swing/text/TextAction.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by mkoch, Fri Oct 22 12:44:01 2004 UTC revision 1.7 by mkoch, Wed Dec 29 13:38:40 2004 UTC
# Line 39  exception statement from your version. * Line 39  exception statement from your version. *
39  package javax.swing.text;  package javax.swing.text;
40    
41  import java.awt.event.ActionEvent;  import java.awt.event.ActionEvent;
42    import java.util.ArrayList;
43    import java.util.HashSet;
44    
45  import javax.swing.AbstractAction;  import javax.swing.AbstractAction;
46  import javax.swing.Action;  import javax.swing.Action;
# Line 59  public abstract class TextAction extends Line 61  public abstract class TextAction extends
61    }    }
62    
63    /**    /**
64     * getTextComponent     * Returns the <code>JTextComponent</code> object associated with the given
65     * @param event TODO     * <code>ActionEvent</code>. If the source of the event is not a
66     * @return JTextComponent     * <code>JTextComponent</code> the currently focused text component is returned.
67       *
68       * @param event the action event
69       *
70       * @return the <code>JTextComponent</code>
71     */     */
72    protected final JTextComponent getTextComponent(ActionEvent event)    protected final JTextComponent getTextComponent(ActionEvent event)
73    {    {
74      if (event.getSource() != null &&      if (event.getSource() instanceof JTextComponent)
         event.getSource() instanceof JTextComponent)  
75        return (JTextComponent) event.getSource();        return (JTextComponent) event.getSource();
76      else  
77        return getFocusedComponent();      return getFocusedComponent();
78    }    }
79    
80    /**    /**
81     * augmentList     * Creates a new array of <code>Action</code> containing both given arrays.
82     * @param list1 TODO     *
83     * @param list2 TODO     * @param list1 the first action array
84     * @return Action[]     * @param list2 the second action array
85       *
86       * @return the augmented array of actions
87     */     */
88    public static final Action[] augmentList(Action[] list1, Action[] list2)    public static final Action[] augmentList(Action[] list1, Action[] list2)
89    {    {
90      return null; // TODO      HashSet actionSet = new HashSet();
91    
92        for (int i = 0; i < list1.length; ++i)
93          actionSet.add(list1[i]);
94    
95        for (int i = 0; i < list2.length; ++i)
96          actionSet.add(list2[i]);
97    
98        ArrayList list = new ArrayList(actionSet);
99        return (Action[]) list.toArray(new Action[actionSet.size()]);
100    }    }
101    
102    /**    /**
103     * getFocusedComponent     * Returns the current focused <code>JTextComponent</code> object.
104     * @return JTextComponent     *
105       * @return the <code>JTextComponent</code>
106     */     */
107    protected final JTextComponent getFocusedComponent()    protected final JTextComponent getFocusedComponent()
108    {    {

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26