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

JCombobox dereferences Vectors members on removeAllItems()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.3.0
    • client-libs



      Name: yyT116575 Date: 02/08/2001


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

      When a JComboBox is constructed with a Vector, and you call .removeAllItems()
      on the JComboBox instead of derefferencing the Vector from the JComboBox
      or derefferencing all items from the JCombobox, it deletes all items from the Vector itself.
      This gave me problems with caching combobox items in my Localized version of my gui.
      Please let me know if this is a bug or a feature, i can work around this problem but I would
      not like to.


      import javax.swing.JComboBox;
      import java.util.Vector;
       
      public class JComboBug {
       
        public static void main(String args[]) {
          Vector myVector = new Vector();
          myVector.add("test1");
          myVector.add("test2");
          myVector.add("test3");
          JComboBox myBox = new JComboBox(myVector);
          System.out.println(myVector.size());
          myBox.removeAllItems();
          System.out.println(myVector.size());
        }
      }

      output:
      3
      0
      (Review ID: 116589)
      ======================================================================

            mdavidsosunw Mark Davidson (Inactive)
            yyoungsunw Yung-ching Young (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: