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; |
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 |
{ |
{ |