import java.awt.Container;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
public class MyJTabbedPane {
private JFrame frame = new JFrame();
private JTabbedPane totalPanel = new JTabbedPane();
private JPanel panel1 = new JPanel();
private JPanel panel2 = new JPanel();
private JButton button1 = new JButton("中国");
private JButton button2 = new JButton("世界");
public MyJTabbedPane(){
//设置框架的属性
frame.setBounds(100, 100, 500, 500);
frame.setVisible(true);
frame.setResizable(false);
//选项卡面板添加到容器中
Container c = frame.getContentPane();
c.add(totalPanel);
totalPanel.add("中国",panel1);
totalPanel.add("世界",panel2);
panel1.setLayout(null);
button1.setBounds(100,100,100,50);
panel1.add(button1);
panel2.add(button2);
}
public static void main(String[] args) {
new MyJTabbedPane();
}
}