Public Methods | |
ChoiceMenu (String[] choices) | |
ChoiceMenu (String[] choices, String label) | |
ChoiceMenu (String[] choices, String label, int layout) | |
void | setLabel (String label) |
void | select (int pos) |
void | select (String str) |
void | setEnabled (boolean enable) |
void | itemStateChanged (ItemEvent e) |
void | addItemListener (ItemListener l) |
Object[] | getSelectedObjects () |
void | removeItemListener (ItemListener l) |
Static Public Attributes | |
final int | VERTICAL = 0 |
final int | HORIZONTAL = 1 |
Protected Attributes | |
Vector | listeners = new Vector() |
|
00039 { 00040 this(choices, "", VERTICAL); 00041 } |
|
00045 { 00046 this(choices, label, VERTICAL); 00047 } |
|
00051 { 00052 this.layout = layout; 00053 00054 if (this.layout == VERTICAL) { 00055 setLayout(new GridLayout(2, 1)); 00056 } else { 00057 setLayout(new FlowLayout(FlowLayout.LEFT)); 00058 } 00059 setBackground(SystemColor.control); 00060 00061 this.label = new Label(label); 00062 this.choice = new Choice(); 00063 this.choices = choices; 00064 00065 for (int i=0; i < choices.length; i++) { 00066 choice.addItem(choices[i]); 00067 } 00068 choice.addItemListener(this); 00069 if (label != "") { 00070 add(this.label); 00071 } 00072 add(choice); 00073 } |
|
00080 { 00081 this.label.setText(label); 00082 } |
|
00086 { 00087 choice.select(pos); 00088 } |
|
00092 { 00093 choice.select(str); 00094 } |
|
00098 { 00099 choice.setEnabled(enable); 00100 } |
|
00107 { 00108 Vector list; 00109 00110 synchronized (this) { 00111 list = (Vector)listeners.clone(); 00112 } 00113 00114 ItemEvent ie = new ItemEvent(this, e.getID(), 00115 e.getItem(), e.getStateChange()); 00116 for (int i = 0; i < list.size(); i++) { 00117 ((ItemListener)list.elementAt(i)).itemStateChanged(ie); 00118 } 00119 } |
|
00126 { 00127 listeners.addElement(l); 00128 } |
|
00132 { 00133 return choice.getSelectedObjects(); 00134 } |
|
00138 { 00139 listeners.removeElement(l); 00140 } |
|
|
|
|
|
|