黎声的博客
leeshawn
全部博文(8)
开源框架(1)
servlet/jsp(2)
swing(3)
jfreechart(2)
2008年(8)
lmn669
fengfeix
simonlu9
分类: Java
2008-03-06 23:33:40
import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.*;//安全卫士360界面基本实现public class MainFrame extends JFrame implements ActionListener{ Box box = Box.createHorizontalBox(); JButton jb1 = new JButton("常用"); JButton jb2 = new JButton("杀毒"); JButton jb3 = new JButton("高级"); JButton jb4 = new JButton("保护"); JButton jb5 = new JButton("求助"); JButton jb6 = new JButton("推荐"); //页签组件 JTabbedPane jtp1 = new JTabbedPane(); JPanel jp1 = new JPanel(); //实际中应该定义一个继承JPanel类来实现 JPanel jp2 = new JPanel(); JPanel jp3 = new JPanel(); JPanel jp4 = new JPanel(); JPanel jp5 = new JPanel(); JTabbedPane jtp2 = new JTabbedPane(); JPanel jp6 = new JPanel(); JPanel jp7 = new JPanel(); //卡片布局 CardLayout card = new CardLayout(); JPanel jps = new JPanel(); public MainFrame() { //添加组件 box.add(jb1); box.add(jb2); box.add(jb3); box.add(jb4); box.add(jb5); box.add(jb6); //设置页签组件布局策略,一行显示 jtp1.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); jtp1.add("基本状态",jp1); jtp1.add("查杀流行木马",jp2); jtp1.add("清理恶评插件",jp3); jtp1.add("管理应用软件",jp4); jtp1.add("修复系统漏洞",jp5); jtp2.add("杀毒",jp6); jtp2.add("在线杀毒",jp7); jps.setLayout(card); jps.add("changyong",jtp1); jps.add("shadu",jtp2); this.add(box,BorderLayout.NORTH); this.add(jps,BorderLayout.CENTER); jb1.addActionListener(this); jb2.addActionListener(this); //展现 this.setSize(500,400); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); } public static void main(String[] args) { new MainFrame(); } public void actionPerformed(ActionEvent e) { if(e.getSource()==jb1) { card.show(jps, "changyong"); } else if(e.getSource()==jb2) { card.show(jps, "shadu"); } } }
效果图如下
上一篇:Box盒式容器使用
下一篇:多线程扫描器java实现
登录 注册