本文介绍了将JScrollPane与JTextArea一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复: Java Textarea ScrollPane
Possible Duplicate: Java Textarea ScrollPane
我有用于在文本区域中显示滚动条的代码,但它实际上并没有工作.有什么建议吗?
I have code for a scrollbar to appear in a textarea but it doesnt really work. Any suggestions?
final JTextArea textArea = new JTextArea(); textArea.setEditable(false); textArea.setBounds(10, 152, 456, 255); textArea.setBorder(border); textArea.setLineWrap(true); sbrText = new JScrollPane(textArea); sbrText.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); panel_1.add(textArea);推荐答案
您需要将JScrollPane添加到面板中,不是 JTextArea.因此应该是:
You need to add the JScrollPane to the panel, not the JTextArea. So instead it should be:
panel_1.add(sbrText);更多推荐
将JScrollPane与JTextArea一起使用
发布评论