United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6940863 Textarea within scrollpane shows vertical scrollbar
JDK-6940863 : Textarea within scrollpane shows vertical scrollbar

Details
Type:
Bug
Submit Date:
2010-04-05
Status:
Closed
Updated Date:
2011-01-19
Project Name:
JDK
Resolved Date:
2010-05-26
Component:
client-libs
OS:
generic
Sub-Component:
javax.swing
CPU:
generic
Priority:
P3
Resolution:
Duplicate
Affected Versions:
7
Fixed Versions:
7

Related Reports
Duplicate:
Relates:

Sub Tasks

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).

                                    

Comments



Hardware and Software, Engineered to Work Together