1 31 package org.objectweb.proactive.examples.doctor; 32 33 public class OfficeWindow extends javax.swing.JFrame implements java.awt.event.ActionListener { 34 35 DisplayPanel pan; 36 javax.swing.JButton bLegend, bExit; 37 Legend legendDlg; 38 39 public OfficeWindow() { 40 java.awt.Container c = getContentPane(); 41 legendDlg = null; 42 java.awt.GridBagLayout lay = new java.awt.GridBagLayout (); 43 java.awt.GridBagConstraints constr = new java.awt.GridBagConstraints (); 44 c.setLayout(lay); 45 46 constr.gridwidth = java.awt.GridBagConstraints.REMAINDER; 47 constr.fill = java.awt.GridBagConstraints.BOTH; 48 constr.weightx = 0.0; 49 pan = new DisplayPanel(); 50 lay.setConstraints(pan, constr); 51 c.add(pan); 52 53 constr.gridwidth = 1; 54 constr.weightx = 1.0; 55 bLegend = new javax.swing.JButton ("Legend"); 56 lay.setConstraints(bLegend, constr); 57 c.add(bLegend); 58 bLegend.addActionListener(this); 59 60 constr.gridwidth = java.awt.GridBagConstraints.REMAINDER; 61 bExit = new javax.swing.JButton ("Exit"); 62 lay.setConstraints(bExit, constr); 63 c.add(bExit); 64 bExit.addActionListener(this); 65 66 this.addWindowListener(new java.awt.event.WindowAdapter () { 67 public void windowClosing(java.awt.event.WindowEvent e) { 68 System.exit(0); 69 } 70 }); 71 } 72 73 public void actionPerformed(java.awt.event.ActionEvent e) { 74 if (e.getSource() == bExit) { 75 System.exit(0); 76 } 77 if (e.getSource() == bLegend) { 78 if (legendDlg == null) 79 legendDlg = new Legend(this, pan); 80 if (legendDlg.isVisible()) 81 legendDlg.setVisible(false); 82 else 83 legendDlg.show(); 84 } 85 } 86 87 public DisplayPanel getDisplay() { 88 return pan; 89 } 90 } | Popular Tags |