KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > proactive > examples > doctor > OfficeWindow


1 /*
2 * ################################################################
3 *
4 * ProActive: The Java(TM) library for Parallel, Distributed,
5 * Concurrent computing with Security and Mobility
6 *
7 * Copyright (C) 1997-2002 INRIA/University of Nice-Sophia Antipolis
8 * Contact: proactive-support@inria.fr
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 *
25 * Initial developer(s): The ProActive Team
26 * http://www.inria.fr/oasis/ProActive/contacts.html
27 * Contributor(s):
28 *
29 * ################################################################
30 */

31 package org.objectweb.proactive.examples.doctor;
32
33 public class OfficeWindow extends javax.swing.JFrame JavaDoc implements java.awt.event.ActionListener JavaDoc {
34
35   DisplayPanel pan;
36   javax.swing.JButton JavaDoc bLegend, bExit;
37   Legend legendDlg;
38
39   public OfficeWindow() {
40     java.awt.Container JavaDoc c = getContentPane();
41     legendDlg = null;
42     java.awt.GridBagLayout JavaDoc lay = new java.awt.GridBagLayout JavaDoc();
43     java.awt.GridBagConstraints JavaDoc constr = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc("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 JavaDoc("Exit");
62     lay.setConstraints(bExit, constr);
63     c.add(bExit);
64     bExit.addActionListener(this);
65
66     this.addWindowListener(new java.awt.event.WindowAdapter JavaDoc() {
67       public void windowClosing(java.awt.event.WindowEvent JavaDoc e) {
68         System.exit(0);
69       }
70     });
71   }
72
73   public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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