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

BasicComboPopup key handling behaivior has been incompatibly changed

    Details

    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      sparc
    • OS:
      solaris_2.6

      Description



      Name: nkR10003 Date: 11/20/2000


      JavaDoc for BasicComboPopup.InvocationKeyHandler class states:
      "This listener watches for the spacebar being pressed and shows/hides the
      popup accordingly." This does not work from JDK1.4 version.

      Please send out CCC request.

      Example below demonstrates this problem:
      ------------------example--------------------
      import javax.swing.*;
      import javax.swing.plaf.basic.*;
      import java.awt.event.*;
      import java.awt.*;
      import java.lang.reflect.*;

      public class test {
          public static void main(String[] args) {
              JFrame frame = new JFrame("Test");
              frame.setSize(100,50);
              String[] data = {"one", "two", "three", "four", "five"};
              final JComboBox comboBox = new JComboBox(data);
              final InnerClassListener showFlag = new InnerClassListener();
              comboBox.setUI(new StubComboBoxUI());
              frame.getContentPane().add(comboBox);
              
              frame.setVisible(true);
              final KeyEvent event =
                      new KeyEvent(comboBox, KeyEvent.KEY_RELEASED,
                      0, 0, KeyEvent.VK_SPACE);
              try {
                  SwingUtilities.invokeAndWait (new Runnable() {
                      public synchronized void run() {
                          ((StubComboBoxUI)comboBox.getUI()).
                                  stubProcessPopupKeyEvent(event);
                          if (comboBox.getUI().isPopupVisible(comboBox)) {
                              showFlag.setFlag();
                          }
                      }
                  });
              } catch (InvocationTargetException ite) {
                  ite.printStackTrace();
              } catch (InterruptedException ie) {
                  ie.printStackTrace();
              }
              
              if (!showFlag.getFlag()) {
                  System.out.println("Test failed: popup was not shown");
                  System.exit(0);
              }
              
              System.out.println("Test passed: OK");
              System.exit(0);
              
          }
      }

      class StubComboBoxUI extends BasicComboBoxUI {
          StubComboBoxUI() {
              super();
          }
          
          public void stubProcessPopupKeyEvent( KeyEvent e ) {
              popup.getKeyListener().keyReleased(e);
          }
      }

      class InnerClassListener {
          private boolean flag = false;

          public boolean getFlag() {
              boolean temp = flag;
              flag = false;
              return temp;
          }
          
          public void setFlag() {
              flag = true;
          }
      }
      ----------------output:----------------------
      java version "1.4.0beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0beta-b40)
      Java HotSpot(TM) Client VM (build 1.4beta-B40, mixed mode)
      -------------------------------
      Test failed: popup was not shown
      =============================================
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, interpreted mode)
      --------------------------------
      Test passed: OK
      ---------------------------------------------
      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              mdavidsosunw Mark Davidson (Inactive)
              Reporter:
              knasunw Kna Kna (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: