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

JComboBox removeAllItems still throwing exception

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.7
    • client-libs



      Name: el35337 Date: 10/05/98


      JComboBox removeAllItems method is throwing exception. Similar to but#4138253. The suggested workaround gets into infinite loop. I'm using swing103 and jdk117.

      Example code:

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

      public class TestCombo extends JComboBox implements ItemListener {
      public TestCombo() {
      super();

      addItem("one");
      addItem("two");
      addItem("three");

      addItemListener(this);
      }

      public void itemStateChanged(ItemEvent e) {
      this.removeAllItems();

      this.addItem("A");
      this.addItem("B");
      this.addItem("C");
      }

      public static void main(String argc[]){ JFrame f = new JFrame("testing");

      TestCombo tc = new TestCombo();

      f.getContentPane().setLayout(new FlowLayout());
      f.getContentPane().add(tc);

      f.setSize(150,100);
      f.setVisible(true);
      }
      }
      (Review ID: 39989)
      ======================================================================

            tsantossunw Tom Santos (Inactive)
            elarsen Erik Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: