JDK-8081487 : [macosx] Issue with getPreferredSize of JTextArea
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: other
  • CPU: x86
  • Submitted: 2015-05-27
  • Updated: 2015-06-01
  • Resolved: 2015-06-01
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.
JDK 9
9Resolved
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.9.0-ea"
Java(TM) SE Runtime Environment (build 1.9.0-ea-b65)
Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b65, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
os x version 10.8.5 build 12F45

A DESCRIPTION OF THE PROBLEM :
getPreferredSize of JTextArea is wrong.
the returned width is one pixel more than the current width


REGRESSION.  Last worked in version 8u60

ADDITIONAL REGRESSION INFORMATION: 
Java(TM) SE Runtime Environment (build 1.8.0_60-ea-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b08, mixed mode)


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The preferred size should be not keep changing.
ACTUAL -
The preferred size keeps getting wider by one pixel.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.Dimension;

import javax.swing.JTextArea;
import javax.swing.SwingUtilities;

public class JTextAreaPreferredSizeTest
{
	public static void main(String[] args)
	{
		SwingUtilities.invokeLater(new Runnable()
		{
			
			@Override
			public void run()
			{
				JTextArea textArea = new JTextArea("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vel mauris eget ante viverra bibendum in ut nulla. Donec varius suscipit arcu, vitae molestie ipsum pharetra eu. Aliquam suscipit sagittis justo. Aliquam erat volutpat. Vivamus dignissim lectus turpis, eget accumsan.");
				textArea.setLineWrap(true);

				for (int index = 0; index < 255; ++index)
				{
					Dimension size = textArea.getPreferredSize();
					textArea.setSize(size);
					
					System.out.println(size);
				}
			}
		});
	}
}

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


Comments
The problem is reproducible on 9-b66. Cannot reproduce it on 8u60-b17
29-05-2015