01: package vicazh.hyperpool.stream;
02:
03: import javax.swing.*;
04:
05: /**
06: * The list selector combo box model
07: *
08: * @author Victor Zhigunov
09: * @version 0.4.0
10: */
11: public class ISelectorListModel extends AbstractListModel implements
12: ComboBoxModel {
13:
14: protected IListSelector selector;
15:
16: public void setSelector(IListSelector selector) {
17: this .selector = selector;
18: }
19:
20: private Object anItem;
21:
22: public void setSelectedItem(Object anItem) {
23: this .anItem = anItem;
24: }
25:
26: public Object getSelectedItem() {
27: return anItem;
28: }
29:
30: public int getSize() {
31: try {
32: return selector.getGroup().getObjects().size();
33: } catch (RuntimeException e) {
34: return 0;
35: }
36: }
37:
38: public Object getElementAt(int index) {
39: return selector.getGroup().getObjects().get(index);
40: }
41:
42: public void insert(int index) {
43: fireIntervalAdded(this , index, index);
44: }
45:
46: public void remove(int index) {
47: fireIntervalRemoved(this, index, index);
48: }
49: }
|