将JScrollPane与JTextArea一起使用

编程入门 行业动态 更新时间:2024-10-09 21:20:56
本文介绍了将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一起使用

本文发布于:2023-11-25 20:22:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1631218.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:JScrollPane   JTextArea

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!