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

KeyEvent for F10 key does not work as documented

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 1.1, 1.1.6, 1.3.0
    • client-libs
    • generic, x86
    • generic, windows_95



      Name: mf23781 Date: 09/01/98


      *Test case:


      KeyTest.java
      ==============

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

      public class KeyTest extends Frame {
              private MenuBar menubar;
              private Menu c_menu;
              private MenuItem c_quit;
              private TestWindow win;
              public static void main(String args[]) {
                      new KeyTest();
              }
              public KeyTest() {
                      super("KeyTest");
                      menubar = new MenuBar();
                      this.setMenuBar(menubar);
                      c_menu = new Menu("Command");
                      menubar.add(c_menu);
                      c_menu.add(c_quit = new MenuItem("Quit"));
                      c_quit.addActionListener(new ActionListener() {
                              public void actionPerformed(ActionEvent e) {
                                      close();
                              }
                      });
                      win = new TestWindow();
                      add(win);
                      pack();
                      show();
              }

              void close() {
                      this.dispose();
              }

          protected void processEvent(AWTEvent e) {
              if(e.getID() != KeyEvent.KEY_RELEASED) {
                  System.out.println("Frame event: " + e);
                  super.processEvent(e);
              }
          }
      }



      TestWindow.java
      ================

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

      public class TestWindow extends Canvas implements KeyListener, MouseListener {

          public TestWindow() {
              setBackground(Color.black);
              setForeground(Color.green);
              requestFocus();

              addKeyListener(this);
              addMouseListener(this);
          }

          public void keyPressed(KeyEvent e) {
              int c;

              c = e.getKeyCode();
              System.out.println("keyPressed = " + c);
          }

          public void keyReleased(KeyEvent e) {
              int c;

              c = e.getKeyCode();
              System.out.println("keyReleased = " + c);
          }

          public void keyTyped(KeyEvent e) {
              char c;

              c = e.getKeyChar();
              System.out.println("keyTyped = " + (int)c);
          }

          public void mouseClicked(MouseEvent e) {
              requestFocus();
          }

          public void mouseEntered(MouseEvent e) { ; }

          public void mouseExited(MouseEvent e) { ; }

          public void mousePressed(MouseEvent e) { ; }

          public void mouseReleased(MouseEvent e) { ; }

          public Dimension getPreferredSize() {
              return(new Dimension(200, 100));
          }

          public void paint(Graphics g) {
          }
      }

      *Symptoms:

      I have been porting a program using the JDK 1.1.6 on a Windows95
      system. I have found that the KeyEvent for the F10 key does not work as documented in the package documentation for awt and awt.event.The F10 keyReleased event is being stolen from my application,apparently to begin the focus traversal functions. Even implementing processEvent()does not allow me to intercept the F10 key and prevent its use for focus traversal.
      I would like to use the key events as they are documented in the
      Java Platform Core API Specification, in which F10 key events are
      available for use just as other key events are. How do I disable any other use of the F10 key when my component has the focus?


      ======================================================================

            son Oleg Sukhodolsky (Inactive)
            miflemi Mick Fleming
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: