开发者

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? Ho开发者_运维问答w can I prevent this?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜