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

XAWT: Selecting current item in a Choice should send ItemEvent

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 5.0
    • 5.0
    • client-libs
    • tiger
    • generic
    • generic

      On Windows and Solaris (MToolkit), when you pop down a Choice and select the currently selected item, an ItemEvent is sent to the ItemListeners. This is not true with XAWT. While it may make more sense (the currentely selected item doesn't technically undergo a state change when it is selected again), it is a change from previous behavior.

      import java.awt.*;
      import java.awt.event.*;

      public class LongChoice {
              public static void main(String[] args) {
                      Frame f = new Frame("LongChoice");
                      Choice c = new Choice();
                      for (int loop = 0; loop < 100; loop++) {
                              c.addItem("Item " + loop);
                      }
                      c.addItemListener(new ItemListener() {
                              public void itemStateChanged(ItemEvent e) {
                                      System.out.println("itemStateChanged");
                              }
                      });
                      f.add(c);
                      f.setSize(200,200);
                      f.setVisible(true);
              }
      }

            bchristi Brent Christian
            bchristi Brent Christian
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: