Reporting an abnormal sequence of Key Event invocation

Mehrali Parkhideh <[email protected]>
Newsgroups gmane.comp.java.ide.netbeans.user,gmane.comp.java.netbeans.user-interface
Message-ID <[email protected]>

-------- Original Message --------
Subject: 	Reporting an abnormal sequence of Key Event invocation
Date: 	Thu, 06 Jan 2005 03:29:29 -0800
From: 	Mehrali Parkhideh <[email protected]>

	



Subject: Reporting an abnormal sequence of Key Event invocation

Dear NetBeans Developers,

    I am using
    - NetBeans IDE 3.6
    - JDK  j2sdk1.4.1_06
    - JRE   Java 2 Standard Edition version 1.4.1
    - Browser Netscape 7.1

    My problem was in receiving KEY EVENTS; so after stripping down the 
program I see the following abnormality.  All code, except one message 
line is generated by IDE 3.6.

    Description of program:
    1) Using java.awt GUI for applet, IDE gives me a BorderLayout.
    2) Label1 was created in North to show a message.
    3) Panel1 was created in West.
    4) Right click on Panel and selected EVENTS / MOUSE / MOUSEPRESSED
    5) Right click on Panel and selected EVENTS / KEY / KEYRELEASED
    6) Right click on BorderLayout and selected EVENTS / MOUSE / 
MOUSEPRESSED
    7) Right click on Panel and selected EVENTS / KEY / KEYRELEASED
 
    Now the anomaly that I observe is the following:
    a) Starting from BROWSER area then clicking on Applet Layout area:
          i) The FormMouse event is called.
          ii) Pressing Key; the FormKey event is called.

    b) Clicking on Panel:
          i) The PanelMouse event is called.
          ii) Pressing Key; the PanelKey event is called.

    c) Now, clicking on Applet Layout Area:
          i) The FormMouse event is called.
          ii) Pressing Key;  the PanelKey event is called.  <<=====

    I was expecting case "c" to be identical to case "a" because mouse 
should have shifted the focus from Panel to Layout area.

    Thank you for your consideration,
    [email protected]

Code generated by IDE with one line message added:
/*
 * Test1.java
 *
 * Created on January 3, 2005, 9:57 AM
 */

/**
 *
 * @author  ap
 */
public class Test1 extends java.applet.Applet {
   
    /** Initializes the applet Test1 */
    public void init() {
        initComponents();
    }
   
    /** This method is called from within the init() method to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {
        label1 = new java.awt.Label();
        panel1 = new java.awt.Panel();

        setLayout(new java.awt.BorderLayout());

        addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                formKeyPressed(evt);
            }
        });
        addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                formMousePressed(evt);
            }
        });

        label1.setText("label1");
        add(label1, java.awt.BorderLayout.NORTH);

        panel1.setBackground(new java.awt.Color(153, 255, 153));
        panel1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                panel1KeyReleased(evt);
            }
        });
        panel1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                panel1MousePressed(evt);
            }
        });

        add(panel1, java.awt.BorderLayout.WEST);

    }

    private void formMousePressed(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
        label1.setText("Form Mouse Pressed.");
    }

    private void panel1MousePressed(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
        label1.setText("Panel Mouse Pressed.");
    }

    private void panel1KeyReleased(java.awt.event.KeyEvent evt) {
        // TODO add your handling code here:
        label1.setText("Panel key =" + evt.getKeyCode() + ", " + 
evt.getKeyText(evt.getKeyCode()));
    }

    private void formKeyPressed(java.awt.event.KeyEvent evt) {
        // TODO add your handling code here:
        label1.setText("Form key =" + evt.getKeyCode() + ", " + 
evt.getKeyText(evt.getKeyCode()));

    }
   
   
    // Variables declaration - do not modify
    private java.awt.Label label1;
    private java.awt.Panel panel1;
    // End of variables declaration
   
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.