//TabbedPaneDemo.java
//多标签,如果希望一个标签内有多个构件,可以引入JPanel
//2009-11-05
//<applet code=TabbedPaneDemo width=200 height=100>
//</applet>
import javax.swing.*;
import java.awt.*;
public class TabbedPaneDemo extends JApplet
{
JTabbedPane tabs=new JTabbedPane();
JPanel panel=new JPanel();
String[] choices={"choice1","choice2","choice3"};//JList参数
String[] selections={"selection1","selection2","selection3"};//JComboBox参数
public void init(){
Container cp=getContentPane();
panel.add(new JList(choices));
panel.add(new JRadioButton("JRadioButton1"));
panel.add(new JComboBox(selections));
panel.add(new JTextField("textField"));
cp.add(tabs);
tabs.addTab("Tab1",new JButton("button"));
tabs.addTab("Tab2",new JLabel("JLable"));
tabs.addTab("Tab3",new JTextField("JTextField",12));
tabs.addTab("Tab4",new JToggleButton("JToggleButton"));
tabs.addTab("Tab5",new JCheckBox("JCheckBox"));
tabs.addTab("Tab6",panel);//作为构件Compoment
}
}
下面的Tab6需要JPanel对象既作容器又作构件。