FileDocCategorySizeDatePackage
EditableComboBox.javaAPI DocExample2949Mon Nov 09 12:45:54 GMT 1998None

EditableComboBox

public class EditableComboBox extends JPanel implements ActionListener

Fields Summary
private String[]
title
Hashtable
hashtable
Constructors Summary
public EditableComboBox()


      
      super(true);

      hashtable = new Hashtable();
      hashtable.put(title[0],new JLabel(new ImageIcon("designjs.s.gif"))); 
      hashtable.put(title[1],new JLabel(new ImageIcon("expjava2.s.gif"))); 
      hashtable.put(title[2],new JLabel(new ImageIcon("javabeans.s.gif"))); 
      hashtable.put(title[3],new JLabel(new ImageIcon("javadata.s.gif"))); 
      hashtable.put(title[4],new JLabel(new ImageIcon("javadeluxe.s.gif")));
      hashtable.put(title[5],new JLabel(new ImageIcon("javafund.s.gif"))); 
      hashtable.put(title[6],new JLabel(new ImageIcon("javalang2.s.gif"))); 
      hashtable.put(title[7],new JLabel(new ImageIcon("javanetwk.s.gif"))); 
      hashtable.put(title[8],new JLabel(new ImageIcon("javanut2.s.gif"))); 
      hashtable.put(title[9],new JLabel(new ImageIcon("javavm.s.gif"))); 
      hashtable.put(title[10],new JLabel(new ImageIcon("javawt.s.gif"))); 
      hashtable.put(title[11],new JLabel(new ImageIcon("jenut.s.gif"))); 
      hashtable.put(title[12],new JLabel(new ImageIcon("jthreads.s.gif"))); 

      setLayout(new BorderLayout()); 

      JComboBox bookCombo = new JComboBox(title);
      bookCombo.setEditable(true);
      bookCombo.setEditor(new ComboBoxEditorExample(hashtable, title[10]));
      bookCombo.setMaximumRowCount(4);
      bookCombo.addActionListener(this);
      bookCombo.setActionCommand("Hello");
      add(bookCombo, BorderLayout.CENTER);
    
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent e)

        System.out.println("You chose " + ((JComboBox)e.getSource()).
                                           getSelectedItem()  + "!"); 
    
public static voidmain(java.lang.String[] s)

         JFrame frame = new JFrame("Combo Box Example");
         frame.addWindowListener(new BasicWindowMonitor());
         frame.setContentPane(new EditableComboBox());
         frame.pack();
         frame.setVisible(true);