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

JComboBox repaint broken in Swing 1.0.2

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.2.0
    • 1.2.0
    • client-libs
    • None
    • swing1.0.3
    • generic
    • generic

      Using setSelectedIndex() of JComboBox doesn't cause the UI to repaint
      the combobox under swing 1.0.2. Is this a bug or was something changed
      where now I need to explicitly tell it to update?

      Here's a sample application that works under 1.0.1 but not 1.0.2.

      import java.awt.*;
      import java.awt.event.*;
      import com.sun.java.swing.*;

      public class combotest {
          JComboBox combo;
          
          public combotest() {
      Object[] items = {"Foo", "Bar", "This", "That", "Bletch", "Gack"};
              JFrame frame = new JFrame("ComboBox Test");
              frame.addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent e) {System.exit(0);}});
      combo = new JComboBox(items);

      // Each button click should display the next item in the combo box
      JButton button = new JButton("Click Me");
      button.addActionListener(new ActionListener () {
      public void actionPerformed(ActionEvent evt) {
      try {
      combo.setSelectedIndex(combo.getSelectedIndex() + 1);
      } catch(IllegalArgumentException e) {
      combo.setSelectedIndex(0);
      }
      }
      });
      frame.getContentPane().setLayout(new BorderLayout());
      frame.getContentPane().add(button);
      frame.getContentPane().add("South", combo);
              frame.pack();
              frame.show();
          }
          
          public static void main(String[] args) {
      new combotest();
          }
          
      } // combotest

            tsantossunw Tom Santos (Inactive)
            rkarsunw Ralph Kar (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: