public class JscrolDemo extends JFrame {
public static void main(String[] args) {
new JscrolDemo();
}
public JscrolDemo() {
Container container = this.getContentPane();
//文本域
JTextArea textArea = new JTextArea(20, 50);
textArea.setText("我在努力学习");
//scrol 面板
JScrollPane scrollPane = new JScrollPane(textArea); //放入有滚动条的面板
container.add(scrollPane);
this.setVisible(true);
this.setBounds(100,100,300,350);
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
}
2021-06-06滚动条de面板
最新推荐文章于 2025-12-02 21:20:38 发布
本文介绍了如何使用Java Swing库创建一个带有滚动条的JScrollPane,包含一个 JTextArea,展示文本并设置窗口位置。通过JFrame实例展示了基本的GUI组件操作。
1万+

被折叠的 条评论
为什么被折叠?



