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

JComboBox popup doesn't initially display selected item

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.3.0, 1.3.1, 1.4.0
    • client-libs
    • 1.3
    • beta
    • generic, x86, sparc
    • generic, solaris_8, windows_nt



      Name: stC104175 Date: 05/11/2000


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      Set a selected index in a JComboBox.
      click on the combo box.
      The scroll box appears at the top and the selected item isn't visible.
      Scrolling down shows the correct item as highlighted.

      click again (twice) to hide/show the list.
      The correct, selected item is now shown.
      As can be seen, the combo box doesn't initially scroll to the right position.

      (In example below should show 2000, but only shows 1900, 1901...)

      package test;
      import javax.swing.*;
      import java.util.Vector;
      public class YearTest extends JFrame
      {
      public YearTest()
      {
      Vector years = new Vector();
      for (int i=0;i<200;i++)
      {
      years.add(new Integer(i+1900));
      }
      JComboBox yearCombo = new JComboBox(years);
      yearCombo.setSelectedIndex(100);
      getContentPane().add(yearCombo);
      setSize(300,300);
      }
      public static void main(String [] args)
      {
      YearTest test = new YearTest();
      test.setDefaultCloseOperation(EXIT_ON_CLOSE);
      test.setVisible(true);
      }
      }
      (Review ID: 104720)
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            stompkinsunw Sean Tompkins (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: