JDK-5061123 : TAB Key Not Generating key events under any circumstances
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.2
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-06-10
  • Updated: 2004-06-10
  • Resolved: 2004-06-10
Related Reports
Duplicate :  
Description

Name: js151677			Date: 06/10/2004


FULL PRODUCT VERSION :
java version "1.4.2_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_03-b02)
Java HotSpot(TM) Client VM (build 1.4.2_03-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP
Professional
Version 2002
Service Pack 1


A DESCRIPTION OF THE PROBLEM :
An AWT TextField does not report TAB events. This behaviour is different to the original 1.1 Java runtime. The code appears to perform tab processing for focus control which then suppresses the corresponding key event. I have overridden a TextField and added a keyListener to the control. In both cases no TAB KeyEvents are generated. The following is code which I used to test the behaviour. This test shows that even when the focus changes from one text field to another, no TAB key events are generated.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile included source and run it, press tab key, no events are generated.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
TAB KeyEvents should be generated for the TextField.
ACTUAL -
No events are generated.

REPRODUCIBILITY :
This bug can be reproduced always.

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

package testing;

import java.awt.AWTEvent;
import java.awt.HeadlessException;
import java.awt.TextField;
import java.awt.event.KeyEvent;


public class MyTextField extends TextField
{

    public MyTextField ( ) throws HeadlessException
    {
        super ( );
        enableEvents(AWTEvent.KEY_EVENT_MASK);
    }

    public MyTextField ( int columns ) throws HeadlessException
    {
        super ( columns );
        enableEvents(AWTEvent.KEY_EVENT_MASK);
    }

    public MyTextField ( String text ) throws HeadlessException
    {
        super ( text );
        enableEvents(AWTEvent.KEY_EVENT_MASK);
    }

    public MyTextField ( String text, int columns ) throws HeadlessException
    {
        super ( text, columns );
        enableEvents(AWTEvent.KEY_EVENT_MASK);
    }
    
    protected void processEvent ( AWTEvent e )
    {
        System.out.println ( "ProcessEvent: " + e ) ;
        super.processEvent ( e );
    }
    
    protected void processKeyEvent ( KeyEvent e )
    {
        System.out.println ( "ProcessKeyEvent: " + e ) ;
        super.processKeyEvent ( e );
    }
}

package testing;

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

import amber.awt.*;

public class TestTextFieldFrame extends Frame implements KeyListener
{
    private MyTextField panel = new MyTextField ( ) ;
    private MyTextField panel2 = new MyTextField ( ) ;
    int level = 0 ;

        public TestTextFieldFrame()
        {
                super();
                init ( ) ;
        }


        public TestTextFieldFrame(String arg0)
        {
                super(arg0);
                init ( ) ;
        }
        
        protected void init ( )
        {
                this.setLayout(new FlowLayout()) ;
                add(panel) ;
                add(panel2) ;
                setBounds(200,200,400,400) ;
                
                addKeyListener ( this ) ;
                panel.addKeyListener(this) ;
                panel2.addKeyListener(this) ;
        }

        public static void main(String[] args)
        {
                TestTextFieldFrame frame = new TestTextFieldFrame ( "Test" ) ;
                frame.setVisible(true);
                frame.getPanel2().requestFocus() ;
    }


        public void keyPressed(KeyEvent e)
        {
                System.out.println ( "Key Pressed: " + e ) ;
        }

        public void keyReleased(KeyEvent e)
        {
                System.out.println ( "Key Released: " + e ) ;
        }

        public void keyTyped(KeyEvent e)
        {
                System.out.println ( "Key Typed: " + e ) ;
        }
}

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

CUSTOMER SUBMITTED WORKAROUND :
There is none.
(Incident Review ID: 275779) 
======================================================================

Comments
EVALUATION Name: rpR10076 Date: 06/10/2004 This issue was reported several times already, for different Components. To be brief, TextField is no different from all other Components - it shouldn't get TAB KeyEvents, as they are focus traversal events. This is explained in detail (with 1.4 spec quotes) in the evaluation of the bug 4650902. ###@###.### ======================================================================
17-09-2004