JDK-6283270 : REGRESSION: JPanel which contains a RTOL JTextArea with LineWrap=True broken
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0,6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2005-06-09
  • Updated: 2010-05-08
  • Resolved: 2005-08-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6
5.0u6Fixed 6 b48Fixed
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.6.0-ea"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-ea-b39)
Java HotSpot(TM) Client VM (build 1.6.0-ea-b39, mixed mode, sharing)

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

A DESCRIPTION OF THE PROBLEM :
When you set a JTextArea to RIGHT_TO_LEFT and setLineWrap to true, then add this text area to a JPanel the entire panel gets blanked out.

But if you don't have lineWrap set it is displayed correctly.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Using the code snippet below just run testLineWrap() you will get 4 successive dialogs showing the different combinations of orientation and lineWrap, and the last dialog which sets the orientation to RIGHT_TO_LEFT and sets the LineWrap true will be a blank dialog.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
You should get 4 dialogs showing all 3 components.

first dialog titled "LtoR No Line Wrap"
"Test Label" [Hello There                           ] TestButton

second dialog titled "LtoR Line Wrap"
"Test Label" [Hello There                          ] TestButton

third dialog titled "RtoL No Line Wrap"
TestButton [                             Hello There] "Test Label"

forth dialog titled "RtoL Line Wrap"
TestButton [                              Hello There] "Test Label"

ACTUAL -
first dialog titled "LtoR No Line Wrap"
"Test Label" [Hello There                           ] TestButton

second dialog titled "LtoR Line Wrap"
"Test Label" [Hello There                          ] TestButton

third dialog titled "RtoL No Line Wrap"
TestButton [                             Hello There] "Test Label"

forth dialog titled "RtoL Line Wrap"
<BLANK>


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
private void testLineWrap()
{
	testDialog("LtoR No Line Wrap", ComponentOrientation.LEFT_TO_RIGHT, false);
	testDialog("LtoR Line Wrap", ComponentOrientation.LEFT_TO_RIGHT, true);
	testDialog("RtoL No Line Wrap", ComponentOrientation.RIGHT_TO_LEFT, false);
	testDialog("RtoL Line Wrap", ComponentOrientation.RIGHT_TO_LEFT, true);
}

private void testDialog(String title, ComponentOrientation orientation, boolean shouldLineWrap)
{
	JTextArea widget = new JTextArea(1, 40);
	widget.setComponentOrientation(orientation);
	widget.setLineWrap(shouldLineWrap);
	widget.setText("hello there");

	JLabel label = new JLabel("Test Label");
	label.setComponentOrientation(orientation);
	
	JButton button = new JButton("Test Button");
	button.setComponentOrientation(orientation);
	
	JPanel panel = new JPanel();
	panel.setLayout(new FlowLayout());
	panel.setComponentOrientation(orientation);
	panel.add(label);
	panel.add(widget);
	panel.add(button);
	
	JDialog dialog = new JDialog((Frame)null, title, true);
	dialog.setComponentOrientation(orientation);
	dialog.getContentPane()(panel, BorderLayout.CENTER);
	dialog.pack();
	dialog.setResizable(true);
	dialog.setVisible(true);
}

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

Release Regression From : 1.4.2
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.
###@###.### 2005-06-09 16:34:18 GMT

Comments
EVALUATION To perform the initial layout we set width and height for a text component to Integer.MAX_VALUE. In BasicTextAreaUI we set preferred width to 100 if it was not initialized yet and has original value of Short.MAX_VALUE. We need to check if the value is Integer.MAX_VALUE instead. Layout manager seems not to be able to handle component with preferred width Integer.MAX_VALUE. -- *** /tmp/geta30862 Thu Aug 4 16:27:09 2005 --- BasicTextAreaUI.java Sat Jul 30 15:50:15 2005 *************** *** 261,270 **** } else { req.minimum = 0; req.preferred = getWidth(); ! if (req.preferred == Short.MAX_VALUE) { // We have been initially set to MAX_VALUE, but we ! // don't want this as our preferred. Short is used ! // here as FlowView returns it as the max size. req.preferred = 100; } } --- 261,269 ---- } else { req.minimum = 0; req.preferred = getWidth(); ! if (req.preferred == Integer.MAX_VALUE) { // We have been initially set to MAX_VALUE, but we ! // don't want this as our preferred. req.preferred = 100; } } --
04-08-2005