[英]Scrollable in JTextArea
I have a class extending JFrame and a JTextArea with the configuration below. 我有一个使用以下配置扩展JFrame和JTextArea的类。 For some reason my Scroll doesn not appear.
由于某种原因,我的滚动条没有出现。 I can't figure out why.
我不知道为什么。
JTextArea ta=new JTextArea();
...
ta.setText(out);
JScrollPane scrollFrame = new JScrollPane(ta);
//ta.setAutoscrolls(true);
scrollFrame.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
scrollFrame.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
add(scrollFrame);
add(ta);
setSize(300, 300);
setResizable(false);
setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
setVisible(true);
For example, Adding a Scrollable JTextArea (Java) 例如, 添加可滚动的JTextArea(Java)
just add the scrollframe and not the JTextArea 只需添加滚动框而不是JTextArea
add(scrollFrame);
// add(ta);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.