package com.company; import javax.swing.*; import java.awt.*; public class Main extends JFrame { Main(){ setBounds(100,100,500,300); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); Container c=getContentPane(); JTextArea area=new JTextArea();//文本域 JScrollPane sp=new JScrollPane(area);//創建滾動面板,給文本域添加滾動條 c.add(sp);//容器添加滾動面板 setVisible(true); } public static void main(String[] args) { new Main(); // write your code here } }