1 package com.bonevich.javax.swing;
2
3 import java.awt.event.ActionEvent;
4 import java.awt.event.ActionListener;
5
6 import javax.swing.ComboBoxEditor;
7 import javax.swing.event.EventListenerList;
8
9 /***
10 * An abstract base class for ComboBoxEditors.
11 */
12 public abstract class AbstractComboBoxEditor implements ComboBoxEditor
13 {
14 //////////////////////////////////////////////////////////
15 // Attributes
16 private EventListenerList _listeners = new EventListenerList();
17
18 //////////////////////////////////////////////////////////
19 // Operations - ComboBoxEditor implementation
20 public void addActionListener(ActionListener listener)
21 {
22 _listeners.add(ActionListener.class, listener);
23 }
24
25 public void removeActionListener(ActionListener listener)
26 {
27 _listeners.remove(ActionListener.class, listener);
28 }
29
30 /***
31 * Selects the text to be edited. This is a do-nothing implementation.
32 */
33 public void selectAll() { }
34
35 /***
36 * Notifies the appropriate registered listeners of an ActionEvent
37 */
38 protected void fireActionPerformed(ActionEvent e)
39 {
40 Object[] listeners = _listeners.getListenerList();
41
42 // traverse the array from last to first
43 for (int i = listeners.length - 2; i >= 0; i-=2)
44 {
45 if (listeners[i] == ActionListener.class)
46 {
47 ( (ActionListener)listeners[i + 1] ).actionPerformed(e);
48 }
49 }
50 }
51
52 } /* end class AbstractComboBoxEditor */
This page was automatically generated by Maven