1 package org.glassbox.gui;
2
3 import javax.swing.DefaultComboBoxModel;
4 import java.util.Vector;
5
6 public class TitledComboBoxModel extends DefaultComboBoxModel {
7 private String _title;
8 private boolean _selection;
9
10 public TitledComboBoxModel(String title) {
11 super();
12 _title = title;
13 _selection = false;
14 }
15
16 public TitledComboBoxModel(String title, Object[] items) {
17 super(items);
18 _title = title;
19 _selection = false;
20 }
21
22 public TitledComboBoxModel(String title, Vector items) {
23 super(items);
24 _title = title;
25 _selection = false;
26 }
27
28 public Object getSelectedItem() {
29 if (!_selection) return _title;
30 else return super.getSelectedItem();
31 }
32
33 public void setSelectedItem(Object item) {
34 if (item != null) _selection = true;
35 super.setSelectedItem(item);
36 }
37 }