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

keyEvent is not being captured by keyListener for F10 key

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.0
    • client-libs
    • generic
    • generic



      Name: skT45625 Date: 05/01/2000


      java version "1.2.2"
      Classic VM (build JDK-1.2.2-W, native threads, symcjit)


      I'm developing an application on Windows 95, and here's the problem. I'd like
      "Ctrl+F10" or just "F10" to invoke a method, but F10 key is not reliable. When
      Ctrl+F10 or F10 is pressed, this event gets passed down to key listener
      only every other time. (All other function keys seem to be fine.)

      Here's a simple code to reproduce this behavior:

      ---- Code start ----

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

      import javax.swing.*;

      public class KeyListenerTest extends JFrame
      {

        public static void main(String[] argv)
        {
          new KeyListenerTest().initFrame();
        }

        void initFrame()
        {
          setBounds(100,100,200,100);
          setTitle("Key Listener Test");
          JLabel l = new JLabel("Press F10 to see the System out...");
          getContentPane().add(l);

          addListeners();

          setVisible(true);
        }

        void addListeners()
        {
          this.addWindowListener
          ( new WindowAdapter()
            { public void windowClosing(WindowEvent e)
              { closeWindow(); } } );

          this.addKeyListener
          (
            new KeyAdapter()
            {
              public void keyPressed(KeyEvent e)
              {
                System.out.println("keyPressed()");
                if(e.getKeyCode()==java.awt.event.KeyEvent.VK_F10)
                {
                  System.out.println("F10 pressed...");
                }
              }
            }
          );

        }

        public void closeWindow()
        {
          setVisible(false);
          dispose();
          System.exit(0);
        }
      }


      ---- Code end ----
      was able to reproduce it on WIN NT also, but not in the Sparc Solaris distribution.

      ###@###.### 2000-05-01
      (Review ID: 104331)
      ======================================================================

            ehawkessunw Eric Hawkes (Inactive)
            skondamasunw Suresh Kondamareddy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: