Reputation: 7922
new JScrollPane(originalText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)
I clearly write "as needed," but the scrollbar appears anyway in the blank JTextArea. Why? How can I prevent this?
Upvotes: 0
Views: 1203
Reputation: 57421
It could be if you specified rows argument in the JTextArea constructor. So the area preferred height is bigger than JScrollPane's height and the vertical scroll is needed.
Upvotes: 1
Reputation: 24791
The code you have given is wrong. Jscrollpane doesn't have a constructor like you have mentioned. I think it should be JTextArea instead.
And the answer for your question lies in your parent layout. Please post your layout structure. In general, trying to change your parent's layout to FlowLayout/BorderLayout should show you different results.
Upvotes: 1