rhombidodecahedron
rhombidodecahedron

Reputation: 7922

Vertical scrollbar always appears for JTextArea, why?

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

Answers (2)

StanislavL
StanislavL

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

Suraj Chandran
Suraj Chandran

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

Related Questions