Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4464514

Merlin: JComboBox item selection probelm

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.4.0
    • client-libs
    • beta2
    • x86
    • windows_2000


      Attached the sample code that demonstrates the JComboBox
      item-selection bug. There 2 problems in this sample code:

        1. one cannot select "red" without first selecting "yellow".

        2. "red" should appear initially by default but does not.

      Do not see both problems on 1.3 and 1.3.1

      Test case
      ===========

      import java.awt.*;
      import javax.swing.*;

      public class JComboBoxBug extends JFrame
      {
      public JComboBoxBug()
      {
      super();
      setTitle("JComboBox Bug");
      getContentPane().add(new MyJComboBoxSubclass());
      pack();
      }

      public static void main(String[] args)
      {
      try {
      UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
      (new JComboBoxBug()).setVisible(true);
      }
      catch (Exception ex) {
      ex.printStackTrace();
      }
      }
      }

      class MyJComboBoxSubclass extends JComboBox
      {
      String[] list = { "red", "yellow" };

      public MyJComboBoxSubclass()
      {
      super();
      loadList();
      setEditable(true);
      }

      public void loadList()
      {
      setEditable(true);
      for (int i = 0; i < list.length; i++){
      addItem(list[i]);
      }
      }
      }

            mdavidsosunw Mark Davidson (Inactive)
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: