日期:2014-05-20 浏览次数:20714 次
package FaultDiagnose;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.TitledBorder;
public class YeYaMain extends JFrame implements ActionListener{
private static final long serialVersionUID = 1L;
JButton jb2 = new JButton(" 一 因 一 果 ");
JButton jb8 = new JButton("非一因一果关系");
JButton jb6 = new JButton(" 返 回 上 层 ");
JButton jb7 = new JButton(" 退 出 系 统 ");
TitledBorder tb1=new TitledBorder("请选择");
JLabel jl1=new JLabel("欢迎");
//创建横向Box容器
private Box box0=Box.createVerticalBox();
private Box box1=Box.createHorizontalBox();
private Box box2=Box.createHorizontalBox();
private Box box3=Box.createVerticalBox();
private Box box4=Box.createVerticalBox();
public YeYaMain(){
super("欢迎");
jb2.setSize(150,25);
jb6.setSize(150,25);
//加入图片
jl1.setBounds(150,100,1000,700); // 设置标签的显示位置及大小
jl1.setFont(new Font("", Font.BOLD, 28));
//加入下拉列表
this.add(box0);
box0.add(Box.createVerticalStrut(30));
box0.add(box1);
box1.add(jl1);
box0.add(Box.createVerticalStrut(15));
box0.add(box2);
box2.add(Box.createHorizontalGlue());
box2.add(box3);
box3.setBorder(new TitledBorder(tb1));
box3.add(Box.createVerticalStrut(22));
box3.add(jb2);
jb2.addActionListener(this);
box3.add(Box.createHorizontalGlue());
box3.add(Box.createVerticalStrut(22));
box3.add(jb8);
jb8.addActionListener(this);
box3.add(Box.createHorizontalGlue());
box3.add(Box.createVerticalStrut(22));
box3.add(jb6);
jb6.addActionListener(this);
box3.add(Box.createHorizontalGlue());
box3.add(Box.createVerticalStrut(22));
box3.add(jb7);
jb7.addActionListener(this);
box3.add(Box.createVerticalStrut(60));
box2.add(Box.createHorizontalGlue());
box2.add(box4);//添加图片
box2.add(Box.createHorizontalGlue());
box0.add(Box.createVerticalStrut(22));
this.setVisible(true);
this.setResizable(false);
this.setBounds(450,60,720,450);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource() == jb2){
HuiMain frame=new HuiMain();
frame.setVisible(true);
this.setVisible(false);
}
if(e.getSource() == jb8){
//DuoxitongMain frame=new DuoxitongMain();
//frame.setVisible(true);
this.setVisible(false);
new DuoxitongMain();
}
if (e.getSource() == jb6){
this.setVisible(false);
new Main2();
}
else
if (e.getSource() ==jb7 ){ //退出系统
System.exit(0);
}
}
}