import java.awt.*;
import javax.swing.*;
import java.awt.event.*;class Setclass extends JFrame implements ActionListener{
JButton b=new JButton("关闭");
public Setclass(){
this.setTitle("课程设置");
this.setSize(600,600);
this.getContentPane().setLayout(new BorderLayout());
JTabbedPane tab=new JTabbedPane();
JPanel p=new JPanel();
this.getContentPane().add(tab,BorderLayout.CENTER);
this.getContentPane().add(p,BorderLayout.SOUTH);
JPanel p1=new JPanel();
JPanel p2=new JPanel();
JPanel p3=new JPanel();
tab.addTab("panel1",p1);
tab.addTab("panel2",p2);
tab.addTab("panel3",p3);
JPanel p1t=new JPanel();
JPanel p1c=new JPanel();
p1.setLayout(new BorderLayout());
p1.add(p1t,BorderLayout.NORTH);
p1.add(p1c,BorderLayout.CENTER);
p1t.add(new JLabel());
JTextArea area1=new JTextArea(20,55);
area1.setLineWrap(true);
p1c.add(new JScrollPane(area1));
area1.enable(false);
area1.setFont(new Font("楷体_GB2312",Font.PLAIN,20));
JPanel p2t=new JPanel();
JPanel p2c=new JPanel();
p2.setLayout(new BorderLayout());
p2.add(p2t,BorderLayout.NORTH);
p2.add(p2c,BorderLayout.CENTER);
p2t.add(new JLabel());
JTextArea area2=new JTextArea(20,55);
area2.setLineWrap(true);
area2.enable(false);
area2.setFont(new Font("楷体_GB2312",Font.PLAIN,20));
p2c.add(new JScrollPane(area2));
JPanel p3t=new JPanel();
JPanel p3c=new JPanel();
p2.setLayout(new BorderLayout());
p3.add(p3t,BorderLayout.NORTH);
p3.add(p3c,BorderLayout.CENTER);
p3t.add(new JLabel());
JTextArea area3=new JTextArea(20,55);
area3.setLineWrap(true);
area3.enable(false);
area3.setFont(new Font("楷体_GB2312",Font.PLAIN,20));
p3c.add(new JScrollPane(area3));
p.add(b);
b.setBackground(new Color(108,147,214));
p.setBackground(new Color(108,147,214));
b.addActionListener(this);
this.show();
}
public void actionPerformed(ActionEvent e){
this.hide();
}
public static void main(String args[]){
new Setclass();
}
}为什么第二个面板的内容显示不出
import javax.swing.*;
import java.awt.event.*;class Setclass extends JFrame implements ActionListener{
JButton b=new JButton("关闭");
public Setclass(){
this.setTitle("课程设置");
this.setSize(600,600);
this.getContentPane().setLayout(new BorderLayout());
JTabbedPane tab=new JTabbedPane();
JPanel p=new JPanel();
this.getContentPane().add(tab,BorderLayout.CENTER);
this.getContentPane().add(p,BorderLayout.SOUTH);
JPanel p1=new JPanel();
JPanel p2=new JPanel();
JPanel p3=new JPanel();
tab.addTab("panel1",p1);
tab.addTab("panel2",p2);
tab.addTab("panel3",p3);
JPanel p1t=new JPanel();
JPanel p1c=new JPanel();
p1.setLayout(new BorderLayout());
p1.add(p1t,BorderLayout.NORTH);
p1.add(p1c,BorderLayout.CENTER);
p1t.add(new JLabel());
JTextArea area1=new JTextArea(20,55);
area1.setLineWrap(true);
p1c.add(new JScrollPane(area1));
area1.enable(false);
area1.setFont(new Font("楷体_GB2312",Font.PLAIN,20));
JPanel p2t=new JPanel();
JPanel p2c=new JPanel();
p2.setLayout(new BorderLayout());
p2.add(p2t,BorderLayout.NORTH);
p2.add(p2c,BorderLayout.CENTER);
p2t.add(new JLabel());
JTextArea area2=new JTextArea(20,55);
area2.setLineWrap(true);
area2.enable(false);
area2.setFont(new Font("楷体_GB2312",Font.PLAIN,20));
p2c.add(new JScrollPane(area2));
JPanel p3t=new JPanel();
JPanel p3c=new JPanel();
p2.setLayout(new BorderLayout());
p3.add(p3t,BorderLayout.NORTH);
p3.add(p3c,BorderLayout.CENTER);
p3t.add(new JLabel());
JTextArea area3=new JTextArea(20,55);
area3.setLineWrap(true);
area3.enable(false);
area3.setFont(new Font("楷体_GB2312",Font.PLAIN,20));
p3c.add(new JScrollPane(area3));
p.add(b);
b.setBackground(new Color(108,147,214));
p.setBackground(new Color(108,147,214));
b.addActionListener(this);
this.show();
}
public void actionPerformed(ActionEvent e){
this.hide();
}
public static void main(String args[]){
new Setclass();
}
}为什么第二个面板的内容显示不出
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;class Setclass extends JFrame implements ActionListener{
JButton b=new JButton("关闭");
public Setclass(){
this.setTitle("课程设置");
this.setSize(600,600);
this.getContentPane().setLayout(new BorderLayout());
JTabbedPane tab=new JTabbedPane();
JPanel p=new JPanel();
JPanel p1=new JPanel();
JPanel p2=new JPanel();
JPanel p3=new JPanel();
JPanel p1t=new JPanel();
JPanel p1c=new JPanel();
p1.setLayout(new BorderLayout());
p1.add(p1t,BorderLayout.NORTH);
p1.add(p1c,BorderLayout.CENTER);
p1t.add(new JLabel());
JTextArea area1=new JTextArea(20,55);
area1.setLineWrap(true);
p1c.add(new JScrollPane(area1));
area1.enable(false);
area1.setFont(new Font("楷体_GB2312",Font.PLAIN,20));
JPanel p2t=new JPanel();
JPanel p2c=new JPanel();
p2.setLayout(new BorderLayout());
p2.add(p2t,BorderLayout.NORTH);
p2.add(p2c,BorderLayout.CENTER);
p2t.add(new JLabel());
JTextArea area2=new JTextArea(20,55);
area2.setLineWrap(true);
p2c.add(new JScrollPane(area2));
area2.enable(false);
area2.setFont(new Font("楷体_GB2312",Font.PLAIN,20));
JPanel p3t=new JPanel();
JPanel p3c=new JPanel();
p3.setLayout(new BorderLayout());
p3.add(p3t,BorderLayout.NORTH);
p3.add(p3c,BorderLayout.CENTER);
p3t.add(new JLabel());
JTextArea area3=new JTextArea(20,55);
area3.setLineWrap(true);
area3.enable(false);
area3.setFont(new Font("楷体_GB2312",Font.PLAIN,20));
p3c.add(new JScrollPane(area3));
p.add(b);
b.setBackground(new Color(108,147,214));
p.setBackground(new Color(108,147,214));
b.addActionListener(this);
this.show();
tab.addTab("panel1",p1);
tab.addTab("panel2",p2);p2.updateUI();
tab.addTab("panel3",p3);
this.getContentPane().add(tab,BorderLayout.CENTER);
this.getContentPane().add(p,BorderLayout.SOUTH);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e){
this.hide();
}
public static void main(String args[]){
new Setclass();
}
}