if(e.getSource() == jb8){
DuoxitongMain frame=new DuoxitongMain();
frame.setVisible(true);
this.setVisible(false);
}
DuoxitongMain frame=new DuoxitongMain();
frame.setVisible(true);
this.setVisible(false);
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class DuoxitongMain {
static final int WIDTH = 400;
static final int HEIGHT = 500;
public static void main(String args[]) {
JFrame frame = new JFrame("TCMESFD");
frame.setSize(WIDTH, HEIGHT);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// 菜单栏
JMenuBar menubar1 = new JMenuBar();// 添加菜单条组件
frame.setJMenuBar(menubar1);// 将菜单条添加到顶层容器中
JMenu menu1 = new JMenu("故障树"); // 设置菜单组件
JMenu menu2 = new JMenu("知识库");
JMenu menu3 = new JMenu("诊断结果");
JMenu menu4 = new JMenu("返回主界面");
JMenu menu5 = new JMenu("帮助");
menubar1.add(menu1);// 将菜单组件添加到菜单条组件中
menubar1.add(menu2);
menubar1.add(menu3);
menubar1.add(menu4);
menubar1.add(menu5);
// 标题、按钮和任务分解和任务分配
JLabel title = new JLabel("欢迎");
JLabel title1 = new JLabel("任务分解");
JLabel title2 = new JLabel("任务分配");
JLabel title3 = new JLabel("诊断结论");
JLabel title4 = new JLabel("建议解决措施");
JToggleButton StartD = new JToggleButton("开始诊断");
JButton StopD = new JButton("停止诊断");
frame.add(title);
frame.add(title1);
frame.add(title2);
frame.add(title3);
frame.add(title4);
frame.add(StartD);
frame.add(StopD);
JTextArea jta1 = new JTextArea("1.任务分解开始;\r\n2.任务分解为4个子任务;\r\n3.任务分解结束;");
JTextArea jta2 = new JTextArea("1.任务分配开始;\r\n2.子任务1分配给Agent9;\r\n3.子任务2分配给Agent2;\r\n"
+ "4.子任务3分配给Agent4;\r\n5.子任务4分配给Agent1;\r\n6.任务分配结束;");
JTextArea jta3 = new JTextArea("诊断时间:2013-5-20 10:08:38\r\n故障代码:dl0056\r\n"
+ "诊断现象:变幅机构、伸缩机构和起升机构均无法动作\r\n故障位置:多路阀系统\r\n故障原因:主安全阀失效");
JTextArea jta4 = new JTextArea("解决措施:多路阀系统主安全阀调定压力不够,排查");
JScrollPane scr1 = new JScrollPane(jta1,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS ,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
JScrollPane scr2 = new JScrollPane(jta2,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS ,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
JScrollPane scr3 = new JScrollPane(jta3,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS ,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
JScrollPane scr4 = new JScrollPane(jta4,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS ,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
frame.add(scr1);
frame.add(scr2);
frame.add(scr3);
frame.add(scr4);
// 故障原因与结果的关系
Container cont = frame.getContentPane();
JRadioButton jrb1 = new JRadioButton("一一对应");
JRadioButton jrb2 = new JRadioButton("一因多果");
JRadioButton jrb3 = new JRadioButton("一果多因");
JPanel pan = new JPanel();
pan.setBorder(BorderFactory.createTitledBorder("故障原因与结果的关系")); // 设置一个边框的显示条
pan.setLayout(new GridLayout(1, 3));
pan.add(jrb1);
pan.add(jrb2);
pan.add(jrb3);
cont.add(pan);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent obj) {
System.exit(1);
}
});
// 任务分解和任务分配
frame.setLayout(null);
title.setBounds(90, 5, 250, 20);
title1.setBounds(15, 55, 250, 20);
title2.setBounds(200, 55, 250, 20);
title3.setBounds(15, 230, 250, 20);
title4.setBounds(15, 350, 250, 20);
StartD.setBounds(70, 30, 100, 20);
StopD.setBounds(220, 30, 100, 20);
pan.setBounds(12, 180, 360, 50);
scr1.setBounds(15, 80, 170, 90);
scr2.setBounds(200,80,170,90) ;
scr3.setBounds(15,250,355,100) ;
scr4.setBounds(15,370,355,60) ;
frame.setVisible(true);
}
};
试一下
public class DuoxitongMain {
static final int WIDTH=400;
static final int HEIGHT=500;
static JFrame frame;
public void setVisible(boolean v) {
frame.setVisible(v);
}
public static void main(String args[]) {
frame=new JFrame("TCMESFD");
frame.setSize(WIDTH,HEIGHT);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// 菜单栏
JMenuBar menubar1=new JMenuBar();// 添加菜单条组件
frame.setJMenuBar(menubar1);// 将菜单条添加到顶层容器中
JMenu menu1=new JMenu("故障树"); // 设置菜单组件
JMenu menu2=new JMenu("知识库");
JMenu menu3=new JMenu("诊断结果");
JMenu menu4=new JMenu("返回主界面");
JMenu menu5=new JMenu("帮助");
menubar1.add(menu1);// 将菜单组件添加到菜单条组件中
menubar1.add(menu2);
menubar1.add(menu3);
menubar1.add(menu4);
menubar1.add(menu5);
// 标题、按钮和任务分解和任务分配
JLabel title=new JLabel("欢迎");
JLabel title1=new JLabel("任务分解");
JLabel title2=new JLabel("任务分配");
JLabel title3=new JLabel("诊断结论");
JLabel title4=new JLabel("建议解决措施");
JToggleButton StartD=new JToggleButton("开始诊断");
JButton StopD=new JButton("停止诊断");
frame.add(title);
frame.add(title1);
frame.add(title2);
frame.add(title3);
frame.add(title4);
frame.add(StartD);
frame.add(StopD);
JTextArea jta1=new JTextArea("1.任务分解开始;\r\n2.任务分解为4个子任务;\r\n3.任务分解结束;");
JTextArea jta2=new JTextArea("1.任务分配开始;\r\n2.子任务1分配给Agent9;\r\n3.子任务2分配给Agent2;\r\n"+"4.子任务3分配给Agent4;\r\n5.子任务4分配给Agent1;\r\n6.任务分配结束;");
JTextArea jta3=new JTextArea("诊断时间:2013-5-20 10:08:38\r\n故障代码:dl0056\r\n"+"诊断现象:变幅机构、伸缩机构和起升机构均无法动作\r\n故障位置:多路阀系统\r\n故障原因:主安全阀失效");
JTextArea jta4=new JTextArea("解决措施:多路阀系统主安全阀调定压力不够,排查");
JScrollPane scr1=new JScrollPane(jta1,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
JScrollPane scr2=new JScrollPane(jta2,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
JScrollPane scr3=new JScrollPane(jta3,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
JScrollPane scr4=new JScrollPane(jta4,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
frame.add(scr1);
frame.add(scr2);
frame.add(scr3);
frame.add(scr4);
// 故障原因与结果的关系
Container cont=frame.getContentPane();
JRadioButton jrb1=new JRadioButton("一一对应");
JRadioButton jrb2=new JRadioButton("一因多果");
JRadioButton jrb3=new JRadioButton("一果多因");
JPanel pan=new JPanel();
pan.setBorder(BorderFactory.createTitledBorder("故障原因与结果的关系")); // 设置一个边框的显示条
pan.setLayout(new GridLayout(1,3));
pan.add(jrb1);
pan.add(jrb2);
pan.add(jrb3);
cont.add(pan);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent obj) {
System.exit(1);
}
});
// 任务分解和任务分配
frame.setLayout(null);
title.setBounds(90,5,250,20);
title1.setBounds(15,55,250,20);
title2.setBounds(200,55,250,20);
title3.setBounds(15,230,250,20);
title4.setBounds(15,350,250,20);
StartD.setBounds(70,30,100,20);
StopD.setBounds(220,30,100,20);
pan.setBounds(12,180,360,50);
scr1.setBounds(15,80,170,90);
scr2.setBounds(200,80,170,90);
scr3.setBounds(15,250,355,100);
scr4.setBounds(15,370,355,60);
frame.setVisible(true);
}
};
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.TitledBorder;public class DuoxitongMain extends JFrame implements ActionListener{
private static final long serialVersionUID = 1L;
static final int WIDTH = 400;
static final int HEIGHT = 500;
public DuoxitongMain(){
super("11");
this.setSize(WIDTH, HEIGHT);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// 菜单栏
JMenuBar menubar1 = new JMenuBar();// 添加菜单条组件
this.setJMenuBar(menubar1);// 将菜单条添加到顶层容器中
JMenu menu1 = new JMenu("故障树"); // 设置菜单组件
JMenu menu2 = new JMenu("知识库");
JMenu menu3 = new JMenu("诊断结果");
JMenu menu4 = new JMenu("返回主界面");
JMenu menu5 = new JMenu("帮助");
menubar1.add(menu1);// 将菜单组件添加到菜单条组件中
menubar1.add(menu2);
menubar1.add(menu3);
menubar1.add(menu4);
menubar1.add(menu5);
// 标题、按钮和任务分解和任务分配
JLabel title = new JLabel("11");
JLabel title1 = new JLabel("任务分解");
JLabel title2 = new JLabel("任务分配");
JLabel title3 = new JLabel("诊断结论");
JLabel title4 = new JLabel("建议解决措施");
JToggleButton StartD = new JToggleButton("开始诊断");
JButton StopD = new JButton("停止诊断");
this.add(title);
this.add(title1);
this.add(title2);
this.add(title3);
this.add(title4);
this.add(StartD);
this.add(StopD);
JTextArea jta1 = new JTextArea("1.任务分解开始;\r\n2.任务分解为4个子任务;\r\n3.任务分解结束;");
JTextArea jta2 = new JTextArea("1.任务分配开始;\r\n2.子任务1分配给Agent9;\r\n3.子任务2分配给Agent2;\r\n"
+ "4.子任务3分配给Agent4;\r\n5.子任务4分配给Agent1;\r\n6.任务分配结束;");
JTextArea jta3 = new JTextArea("诊断时间:2013-10-20 10:08:38\r\n故障代码:dl0056\r\n"
+ "诊断现象:变幅机构、伸缩机构和起升机构均无法动作\r\n故障位置:多路阀系统\r\n故障原因:主安全阀失效");
JTextArea jta4 = new JTextArea("解决措施:多路阀系统主安全阀调定压力不够,排查");
JScrollPane scr1 = new JScrollPane(jta1,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS ,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
JScrollPane scr2 = new JScrollPane(jta2,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS ,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
JScrollPane scr3 = new JScrollPane(jta3,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS ,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
JScrollPane scr4 = new JScrollPane(jta4,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS ,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
this.add(scr1);
this.add(scr2);
this.add(scr3);
this.add(scr4);
// 故障原因与结果的关系
Container cont = this.getContentPane();
JRadioButton jrb1 = new JRadioButton("一一对应");
JRadioButton jrb2 = new JRadioButton("一因多果");
JRadioButton jrb3 = new JRadioButton("一果多因");
JPanel pan = new JPanel();
pan.setBorder(BorderFactory.createTitledBorder("故障原因与结果的关系")); // 设置一个边框的显示条
pan.setLayout(new GridLayout(1, 3));
pan.add(jrb1);
pan.add(jrb2);
pan.add(jrb3);
cont.add(pan);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent obj) {
System.exit(1);
}
});
// 任务分解和任务分配 this.setLayout(null);
title.setBounds(90, 5, 250, 20);
title1.setBounds(15, 55, 250, 20);
title2.setBounds(200, 55, 250, 20);
title3.setBounds(15, 230, 250, 20);
title4.setBounds(15, 350, 250, 20);
StartD.setBounds(70, 30, 100, 20);
StopD.setBounds(220, 30, 100, 20);
pan.setBounds(12, 180, 360, 50);
scr1.setBounds(15, 80, 170, 90);
scr2.setBounds(200,80,170,90) ;
scr3.setBounds(15,250,355,100) ;
scr4.setBounds(15,370,355,60) ;
this.setVisible(true); }
public void actionPerformed(ActionEvent e) {
}
}