Skip to main content

Java 7, Windows LAF: textarea within scrollpane shows vertical scrollbar

1 reply [Last post]
tsinger
Offline
Joined: 2003-06-10

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

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

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ru_pashka
Offline
Joined: 2007-04-23

Hi

Thanks for the report of that. I filed a new bug: http://bugs.sun.com/view_bug.do?bug_id=6940863 (it will be available some time later)...

Thanks, Pavel