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

class Choice: select already selected item then no action occurs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • 9
    • 7u72, 8u20, 8u25, 8u40, 9
    • client-libs
    • x86
    • windows_8

      FULL PRODUCT VERSION :
      1.8.0_25
      1.7 (maybe there is the same bug already in)
      1.6 (it works, no bug)

      ADDITIONAL OS VERSION INFORMATION :
      Windows 8.1

      A DESCRIPTION OF THE PROBLEM :
      class Choice

      if a already selected item ist select again, then no action occurs.
      (An action occurs only if another item ist selected.)



      REGRESSION. Last worked in version 6u43

      ADDITIONAL REGRESSION INFORMATION:
      1.8.0_25

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a Choice.
      Add some items to the Choice
      Add the Choice to a Panel.

      Start Program.

      Select the already selected item.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The method action of the panel should be called.
      ACTUAL -
      The action of the panel is not called.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------



      ChoiceTest.java
      ----------------------
      import java.awt.*;
      import java.awt.event.*;

      public class ChoiceTest extends Frame implements ActionListener {

        Choice myChoice;

        public ChoiceTest() {

          setSize(450, 250);
          addWindowListener(new BasicWindowMonitor());
        
          Panel toolbar = new Panel();
          toolbar.setLayout(new FlowLayout(FlowLayout.LEFT));

          myChoice = new Choice();
          myChoice.add("element 1");
          myChoice.add("element 2");
          myChoice.add("element 3");
          toolbar.add(myChoice);

          add(toolbar, BorderLayout.NORTH);
        }

        public void actionPerformed(ActionEvent ae) {
          System.out.println(ae.getActionCommand());
        }

        public boolean action(Event e,Object o) {
          System.out.println(">>> action: " + myChoice.getSelectedItem());
          return true;
        }

        public static void main(String args[]) {
          ChoiceTest ct = new ChoiceTest();
          ct.setVisible(true);
        }
      }

      BasicWindowMonitor.java
      -----------------------------------
      import java.awt.event.*;
      import java.awt.Window;

      public class BasicWindowMonitor extends WindowAdapter {

        public void windowClosing(WindowEvent e) {
          Window w = e.getWindow();
          w.setVisible(false);
          w.dispose();
          System.exit(0);
        }
      }

      ---------- END SOURCE ----------

            pchelko Petr Pchelko (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: