Horus Doc || Java GUI Reference || Doxygen's quick Index  

ChoiceMenu Class Reference

List of all members.

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()

Constructor & Destructor Documentation

ChoiceMenu::ChoiceMenu String    choices[] [inline]
 

00039     {
00040         this(choices, "", VERTICAL);
00041     }

ChoiceMenu::ChoiceMenu String    choices[],
String    label
[inline]
 

00045     {
00046         this(choices, label, VERTICAL);
00047     }

ChoiceMenu::ChoiceMenu String    choices[],
String    label,
int    layout
[inline]
 

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     }


Member Function Documentation

void ChoiceMenu::setLabel String    label [inline]
 

00080     {
00081         this.label.setText(label);
00082     }

void ChoiceMenu::select int    pos [inline]
 

00086     {
00087         choice.select(pos);
00088     }

void ChoiceMenu::select String    str [inline]
 

00092     {
00093         choice.select(str);
00094     }

void ChoiceMenu::setEnabled boolean    enable [inline]
 

00098     {
00099         choice.setEnabled(enable);
00100     }

void ChoiceMenu::itemStateChanged ItemEvent    e [inline]
 

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     }

void ChoiceMenu::addItemListener ItemListener    l [inline]
 

00126     {
00127         listeners.addElement(l);
00128     }

Object [] ChoiceMenu::getSelectedObjects   [inline]
 

00132     {
00133         return choice.getSelectedObjects();
00134     }

void ChoiceMenu::removeItemListener ItemListener    l [inline]
 

00138     {
00139         listeners.removeElement(l);
00140     }


Member Data Documentation

final int ChoiceMenu::VERTICAL = 0 [static]
 

final int ChoiceMenu::HORIZONTAL = 1 [static]
 

Vector ChoiceMenu::listeners = new Vector() [protected]
 


The documentation for this class was generated from the following file:
Generated on Mon Jan 27 15:11:17 2003 for JavaReference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001