主要实现JScrollPane,滚动条
package lesson03;
import javax.swing.*;
import java.awt.*;
public class TestJScroll extends JFrame {
public TestJScroll() {
Container container = this.getContentPane();
//设置文本域,几行几列
JTextArea textArea = new JTextArea(20, 50);
textArea.setText("gui编程");
//设置面板,加载文本域
JScrollPane scrollPane = new JScrollPane(textArea);
//将面板加载到容器
container.add(scrollPane);
this.setVisible(true);
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
this.setSize(400,400);
}
public static void main(String[] args) {
new TestJScroll();
}
}