JDK-5087785 : Cursor keys in AWT Textarea on JTabbedPane doesn't work
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2004-08-17
  • Updated: 2006-10-10
Related Reports
Relates :  
Description
Name: js151677			Date: 08/16/2004


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

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

A DESCRIPTION OF THE PROBLEM :
If a awt TextArea is located on a JTabbedPane it is no longer possible to move through the written text in the TextArea. Instead the JTabbedPane changes it's selected Tab.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just put a java.awt.TextArea on a JTabbedPane and write some text.
Now try to move through the text by using the cursor keys.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would recommend that the cursor moves left / right / up / down in the TextArea if I press the recommended key. (Just like the behaviour of the JTextArea on a JTabbedPane)
ACTUAL -
The JTabbedPane changes its TAB if I press the cursor key's.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;
import javax.swing.*;

public class MyMainClass
{
	public MyMainClass()
	{
		super();
	}

	public static void main(String[] args)
	{
		MyMainClass aMain = new MyMainClass();
		aMain.testTextAreaProblem();
	}

	public void testTextAreaProblem()
	{
		JFrame aJF = new JFrame("TextArea Test");
		aJF.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		Panel aPL1 = new Panel(new BorderLayout());
		Panel aPL2 = new Panel(new BorderLayout());
		TextArea aTA1 = new TextArea(5, 10);
		JTextArea aTA2 = new JTextArea(5, 10);
		aPL1.add(aTA1, BorderLayout.CENTER);
		aPL2.add(new JScrollPane(aTA2), BorderLayout.CENTER);
		JTabbedPane aJTP = new JTabbedPane();
		aJTP.addTab("AWT", aPL1);
		aJTP.addTab("SWING", aPL2);
		aJF.getContentPane().add(aJTP);
		aJF.pack();
		aJF.show();
	}
}
---------- END SOURCE ----------
(Incident Review ID: 297189) 
======================================================================

Comments
EVALUATION Looks like an editing issue in AWT text area. Transferring to the AWT. ###@###.### 2004-08-17 AWT does nothing about changing tabs for JTabbedPane :) In fact this might be the problem of mixing lightweights and heavyweights. Anyway because it's JTabbedPane who demostrates incorrect behavior, I reassign the problem to the Swing team for initial investigation. ###@###.### 2004-08-18 During this test, the AWT TextArea is the focus owner. It should be getting the key events first. For some reason, it appears that Swing's JTabbedPane is getting first crack at the event. I think this is wrong and an AWT bug. ###@###.### 2004-08-18 The problem is as follows: Swing uses KeyEventPostProcessor to process keybindings (see UIManager). In this post processor Swing tries to process all key events which are targeted to non-swing (not instance of JComponent) components (in our case this is TextArea). If the given key event is recognized as key binding then keybinding is processed and the event is consumed. Thus current tab in JTabbedPane is changed and cursor position in TextArea is not changed, because peers do not process consumed key event. We should keep in mind this problem when/if we will implement RFE 4811096 (Allow mixing of heavy and lightweight components). ###@###.### 2004-08-19
19-08-2004