Class EnumeratedChoice

java.lang.Object
java.awt.Component
java.awt.Choice
wt.clients.util.EnumeratedChoice
All Implemented Interfaces:
ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible

public class EnumeratedChoice extends Choice
This class allows the selection of the allowable values for a specified EnumeratedType class in a choice list.



Supported API: true

Extendable: false Sample code:


        static public void main(String args[])
        {
            if (args.length == 0 )
            {
                System.out.println("supply enumeration class");
                return;
            }

            String classname = args[0];
                class DriverFrame extends java.awt.Frame
                {
                    EnumeratedChoice choice = null;
                        public DriverFrame(String title)
                        {
                super(title);
                                addWindowListener(new java.awt.event.WindowAdapter() {
                                        public void windowClosing(java.awt.event.WindowEvent event)
                                        {
                                                dispose();        // free the system resources
                                                System.exit(0); // close the application
                                        }
                                });
                                setLayout(new java.awt.BorderLayout());
                                setSize(300,300);
                                choice = new EnumeratedChoice();
                                choice.setDisplayNonSelectable(true);
                                
                                add(choice, "Center");
                                
                                choice.addItemListener( new java.awt.event.ItemListener() {
                                    public void itemStateChanged(ItemEvent ie)
                                    {
                                        EnumeratedType value = choice.getSelectedEnumeratedType();
                                        System.out.println("Selected value is now " + value);
                                    }
                                });
                        }
                        public void setClass(String name)
                        {
                                try {
                                    choice.setEnumeratedTypeClassName(name);
                            }
                            catch(PropertyVetoException pve)
                            {
                                pve.printStackTrace();
                            }
                        }

                        public void setClass(Class a_class)
                        {
                                try {
                                    choice.setEnumeratedTypeClass(a_class);
                            }
                            catch(PropertyVetoException pve)
                            {
                                pve.printStackTrace();

                            }
                    }
                }
        DriverFrame df;
        df = new DriverFrame("EnumeratedChoice Test");
        df.setClass(classname);
        df.show();
        }
        
 
See Also: