将JPanel面板作为一个整体的组件添加到JScrollPane面板上
public class TestJScrollPane {
public void creatJScrollPane(){JTextArea ta=new JTextArea(20,50);
ta.setText("演示JScrollPane");
JScrollPane jsp=new JScrollPane(ta);
JFrame jf=new JFrame("演示JScrollPane的JFrame窗体");
jf.setSize(500,300);
jf.setLocation(200,200);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setVisible(true);
jf.add(jsp);
}
public static void main(String[] args) {
TestJScrollPane tjsp=new TestJScrollPane();
tjsp.creatJScrollPane();
}
}