JDK-6940863 : Textarea within scrollpane shows vertical scrollbar
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2010-04-05
  • Updated: 2011-01-19
  • Resolved: 2010-05-26
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 7
7Resolved
Related Reports
Duplicate :  
Relates :  
Description
When invoking the following code on Java 6, the vertical scrollbar is shown if too much text is entered to fit into the visible area. With Java 7, the vertical scrollbar is already shown initially and disappears if entering some text. It remains disappeared if all text is removed.

import java.awt.*;
import javax.swing.*;
 
public class Java7ScrollPaneTest {
 
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				try {
					UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
				}
				catch (Exception ex) {
					ex.printStackTrace();
				}
 
				final JTextArea textArea = new JTextArea();
				textArea.setLineWrap(true);
				textArea.setWrapStyleWord(true);
 
				final JScrollPane scrollPane = new JScrollPane(textArea);
				scrollPane.setMinimumSize(new Dimension(200, 100));
				scrollPane.setPreferredSize(new Dimension(300, 150));
 
				final JFrame frame = new JFrame("Vertical scrollbar shown without text");
				frame.setContentPane(scrollPane);
				frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				frame.pack();
				frame.setVisible(true);
			}
		});
	}
}


I've tried it on Windows XP Pro SP3 with Java 7 ea b86 (2010-03-18).