Swing组件基础-----Scroll面板(带滚动条)

import java.awt.*;
import javax.swing.*;

public class JScrollDemo extends JFrame{
	
	public JScrollDemo() {
		Container container = this.getContentPane();
		
		//文本域
		JTextArea textArea = new JTextArea(20,50);
		textArea.setText("欢迎和Steven一起练Java");
		
		//Scroll面板
		JScrollPane scrollPane = new JScrollPane(textArea);
		container.add(scrollPane);
		
		this.setVisible(true);
		this.setBounds(100,100,300,350);
		this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
	}
	
	public static void main(String[] args) {
		new JScrollDemo();
	}
}

效果:
image

posted @ 2021-05-01 12:47  Steven·Park  阅读(454)  评论(0)    收藏  举报