/*卡片选项页面*/
class TtpDemo extends JFrame{
TtpDemo(){
super("卡片选项页面示例");
setSize(300,200);setVisible(ture);setLoction(500,100);
JTabbedPane jtp = new JTabbedPane();
ImageIcon icon1 = new ImageIcon("c1.gif");
ImageIcon icon2 = new ImageIcon("c2.gif");
ImageIcon icon3 = new ImageIcon("c3.gif");
jtp.addTab("城市",icon1, new CitiesPanel(),"城市名称");
jtp.addTab("文学",icon2, new BookPanel(),"文学书目");
jtp.addTab("网站",icon3, new NetPanel(),"精选网站");
getContenPane().add(jtp);
validate();
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
system.exit(0)}});
}
}
//定义面板CitiesPanel
class CitiesPanel extends JPanel{
CitiesPanel(){
JButton b1 = new JButton("BJ");
JButton b2 = new JButton("SH");
JButton b3 = new JButton("SZ");
JButton b4 = new JButton("XM");
add(b1);add(b2);add(b3);add(b4);
}
}
//定义面板BookPanel
class BookPanel extends JPanel{
BookPanel(){
JCheck cb1 = new JCheck("XYJ");
JCheck cb2 = new JCheck("SGYY");
JCheck cb3 = new JCheck("HLM");
add(cb1);add(cb2);add(cb3);
}
}
class NetPanel extends JPanel{
NetPanel(){
JComboBox jbc = new JComboBox();
jcb.addItem("SWLT");
jcb.addItem("BDSS");
jcb.addItem("JavaAHZ");
add(jcb);
}
}
//主类
public class Example{
public static void main(String args[]){
new TtpDome();
}
}