01: package examples;
02:
03: import javax.swing.*;
04: import vicazh.hyperpool.*;
05: import java.awt.event.*;
06:
07: public class IExampleSelector extends ISelector implements
08: ExampleSelectorMBean, ActionListener {
09:
10: private DefaultComboBoxModel model;
11:
12: /**
13: * @param name
14: * selector name
15: * @param model
16: * combo box model
17: */
18: public IExampleSelector(String name, DefaultComboBoxModel model) {
19: super (ExampleSelectorMBean.class, name);
20: this .model = model;
21: }
22:
23: public void actionPerformed(ActionEvent e) {
24: setDef(((JComboBox) e.getSource()).getSelectedIndex());
25: }
26:
27: public void setGroup(GroupMBean group) {
28: super .setGroup(group);
29: for (Object o : group.getObjects())
30: model.addElement(o);
31: }
32:
33: public void added(int index) {
34: model
35: .insertElementAt(getGroup().getObjects().get(index),
36: index);
37: }
38:
39: public void removed(int index) {
40: model.removeElementAt(index);
41: }
42:
43: protected void otherNotification(String type, Object value) {
44: if (type.equals(ExampleSelectorMBean.DEF))
45: model.setSelectedItem(model.getElementAt((Integer) value));
46: }
47: }
|