JDK-6668883 : First character does not show in JTextArea when tabbed in from another JTextArea
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2008-02-28
  • Updated: 2011-02-16
  • Resolved: 2008-04-15
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_02"
Java(TM) SE Runtime Environment (build 1.6.0_02-b05)
Java HotSpot(TM) Client VM (build 1.6.0_02-b05, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
win2000

A DESCRIPTION OF THE PROBLEM :
Bug 6202684 is still not solved. The problem still exists, when you tab with ctrl-tab from one textarea to another textarea. Sometimes the first character is not shown.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just create several JTextArea components, jump from one textarea to the next with ctrl-tab and type some keys.
Using the Robot-class it should be easy to reproduce the problem (on 1.6.0_05-ea-b04, windows). Only in the first TextArea the first typed key is shown, in every next textarea the first character is lost.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The first typed character should be shown always
ACTUAL -
Sometimes the first typed character is not shown.

REPRODUCIBILITY :
This bug can be reproduced occasionally.

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


import java.awt.Robot;
import java.awt.event.KeyEvent;

import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.JTextArea;


public class Test
{

    /**
     * @param args
     */
    public static void main(final String[] args)
    {
        try
        {
            final javax.swing.JDialog dialog = new javax.swing.JDialog();
            final JPanel panel = new JPanel();
            panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

            dialog.getContentPane().add(panel);
            panel.add(new JTextArea());
            panel.add(new JTextArea());
            panel.add(new JTextArea());
            panel.add(new JTextArea());

            dialog.setVisible(true);
            dialog.setBounds(0, 0, 300, 300);
            Thread.sleep(1000);

            final Robot robot = new Robot();
            System.out.println(System.getProperty("java.version"));

            for (int i = 0; i < 10; i++)
            {
                robot.keyPress(KeyEvent.VK_1);
                robot.keyRelease(KeyEvent.VK_1);
                Thread.sleep(1000);
                robot.keyPress(KeyEvent.VK_2);
                robot.keyRelease(KeyEvent.VK_2);
                Thread.sleep(1000);
                robot.keyPress(KeyEvent.VK_3);
                robot.keyRelease(KeyEvent.VK_3);
                Thread.sleep(1000);

                robot.keyPress(KeyEvent.VK_CONTROL);
                robot.keyPress(KeyEvent.VK_TAB);
                robot.keyRelease(KeyEvent.VK_CONTROL);
                robot.keyRelease(KeyEvent.VK_TAB);
                Thread.sleep(1000);
            }
        }
        catch (Exception exc)
        {
            exc.printStackTrace();
        }
    }
}


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

Comments
EVALUATION Problem no longer reproducible with the fix for 6637607. Closing as duplicate.
15-04-2008

EVALUATION The problem disappears if I change the order of releasing TAB and CTRL keys in the test. Still, I'm able to reproduce the bug manually with 6u1 and 7.0-b21, without usage of Robot class.
28-02-2008