JDK-6202684 : First character does not show in JTextArea when tabbed in from another JTextArea
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2004-12-01
  • Updated: 2004-12-06
  • Resolved: 2004-12-06
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.4.2_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03)
Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000
5.00.2195
Service Pack 4

A DESCRIPTION OF THE PROBLEM :
When you traverse from JTextArea to another JTextArea with keyboard(using Ctrl+Tab) , the first character typed in does not show(gets consumed).

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Have about of 4-6 JTextAreas on a JFrame(or any container) in any fashion.  Now use keyboard(ctrl+tab) to traverse from one JTextArea to the other, type in a word and notice if the entire word shows, now keep repeating this step, you are bound to see that the first character of the word is not  typed in.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
All printable characters should appear in the JTextArea regardless of how the user entered the field (via mouse clicks or  keyboard traversal)
ACTUAL -
First character of the word is consumed without displaying in the field when tabbed into a JTextArea from another JTextArea using the keyboard.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class FrameConsumer extends JFrame {
  JTextArea jTextArea1 = new JTextArea();
  JTextArea jTextArea2 = new JTextArea();
  JTextArea jTextArea3 = new JTextArea();
  JTextArea jTextArea4 = new JTextArea();
  FlowLayout flowLayout1 = new FlowLayout();
  GridLayout gridLayout1 = new GridLayout();

  public FrameConsumer() {
    setTitle("Consuming Characters");
    getContentPane().setLayout(gridLayout1);
    jTextArea1.setBorder(BorderFactory.createLoweredBevelBorder());
    jTextArea4.setBorder(BorderFactory.createLoweredBevelBorder());
    jTextArea3.setBorder(BorderFactory.createLoweredBevelBorder());
    jTextArea2.setBorder(BorderFactory.createLoweredBevelBorder());
    gridLayout1.setVgap(5);
    this.getContentPane().add(jTextArea1, null);
    gridLayout1.setColumns(1);
    gridLayout1.setRows(4);
    this.getContentPane().add(jTextArea2, null);
    this.getContentPane().add(jTextArea3, null);
    this.getContentPane().add(jTextArea4, null);
    this.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        this_windowClosing(e);
      }
    });
  }

  public void this_windowClosing(WindowEvent e) {
    System.exit(0);
  }

  public static void main(String[] args) {
    FrameConsumer frame = new FrameConsumer();
    frame.setSize(400, 400);
    frame.show();
  }
}
---------- END SOURCE ----------


Comments
EVALUATION I think this may be an AWT bug. If I add a KeyListener to the text fields, when the problem occurs, we're actually not seeing a keyTyped event for the missing character. It appears that we do see keyPressed and keyReleased though. Having swing-text take a quick peek first, in case there's something I've missed, but I assume this will be re-assigned to AWT. ###@###.### 2004-12-02 15:52:23 GMT Reproducible on Win2000 with JDK1.4.2. Not with Tiger since it was fixed by the fix for 4782886. ###@###.### 2004-12-06 12:35:13 GMT
02-12-2004