KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > poa > gui > beans > CloseButtonPanel


1 package org.jacorb.poa.gui.beans;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1997-2004 Gerald Brose.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */

22
23 /**
24  * Panel with a Close Button
25  *
26  * @author Reimo Tiedemann, FU Berlin
27  * @version 1.01, 05/10/99
28  */

29 public class CloseButtonPanel extends java.awt.Panel JavaDoc implements java.awt.event.ActionListener JavaDoc {
30     private CloseButtonPanelController controller = null;
31     private String JavaDoc buttonLabel = "Close";
32     private java.awt.FlowLayout JavaDoc ivjCloseButtonPanelFlowLayout = null;
33     private java.awt.Button JavaDoc ivjCloseButton = null;
34 /**
35  * Constructor
36  */

37 /* WARNING: THIS METHOD WILL BE REGENERATED. */
38 public CloseButtonPanel() {
39     super();
40     initialize();
41 }
42 /**
43  * CloseButtonPanel constructor comment.
44  * @param layout java.awt.LayoutManager
45  */

46 public CloseButtonPanel(java.awt.LayoutManager JavaDoc layout) {
47     super(layout);
48 }
49 private void _actionCloseButtonPressed() {
50     if (controller != null) {
51         controller._actionCloseButtonPressed();
52     }
53 }
54 public void _init(CloseButtonPanelController _controller, String JavaDoc _buttonLabel) {
55     controller = _controller;
56     buttonLabel = _buttonLabel;
57     getCloseButton().setLabel(" "+buttonLabel+" ");
58 }
59 /**
60  * Method to handle events for the ActionListener interface.
61  * @param e java.awt.event.ActionEvent
62  */

63 /* WARNING: THIS METHOD WILL BE REGENERATED. */
64 public void actionPerformed(java.awt.event.ActionEvent JavaDoc e) {
65     // user code begin {1}
66
// user code end
67
if ((e.getSource() == getCloseButton()) ) {
68         connEtoC1(e);
69     }
70     // user code begin {2}
71
// user code end
72
}
73 /**
74  * connEtoC1: (Button1.action.actionPerformed(java.awt.event.ActionEvent) --> CloseButtonPanel._actionCloseButtonPressed()V)
75  * @param arg1 java.awt.event.ActionEvent
76  */

77 /* WARNING: THIS METHOD WILL BE REGENERATED. */
78 private void connEtoC1(java.awt.event.ActionEvent JavaDoc arg1) {
79     try {
80         // user code begin {1}
81
// user code end
82
this._actionCloseButtonPressed();
83         // user code begin {2}
84
// user code end
85
} catch (java.lang.Throwable JavaDoc ivjExc) {
86         // user code begin {3}
87
// user code end
88
handleException(ivjExc);
89     }
90 }
91 /**
92  * Return the Button1 property value.
93  * @return java.awt.Button
94  */

95 /* WARNING: THIS METHOD WILL BE REGENERATED. */
96 private java.awt.Button JavaDoc getCloseButton() {
97     if (ivjCloseButton == null) {
98         try {
99             ivjCloseButton = new java.awt.Button JavaDoc();
100             ivjCloseButton.setName("CloseButton");
101             ivjCloseButton.setLabel(" Close ");
102             // user code begin {1}
103
// user code end
104
} catch (java.lang.Throwable JavaDoc ivjExc) {
105             // user code begin {2}
106
// user code end
107
handleException(ivjExc);
108         }
109     };
110     return ivjCloseButton;
111 }
112 /**
113  * Return the CloseButtonPanelFlowLayout property value.
114  * @return java.awt.FlowLayout
115  */

116 /* WARNING: THIS METHOD WILL BE REGENERATED. */
117 private java.awt.FlowLayout JavaDoc getCloseButtonPanelFlowLayout() {
118     java.awt.FlowLayout JavaDoc ivjCloseButtonPanelFlowLayout = null;
119     try {
120         /* Create part */
121         ivjCloseButtonPanelFlowLayout = new java.awt.FlowLayout JavaDoc();
122         ivjCloseButtonPanelFlowLayout.setAlignment(java.awt.FlowLayout.RIGHT);
123         ivjCloseButtonPanelFlowLayout.setHgap(10);
124     } catch (java.lang.Throwable JavaDoc ivjExc) {
125         handleException(ivjExc);
126     };
127     return ivjCloseButtonPanelFlowLayout;
128 }
129 /**
130  * Called whenever the part throws an exception.
131  * @param exception java.lang.Throwable
132  */

133 private void handleException(Throwable JavaDoc exception) {
134
135     /* Uncomment the following lines to print uncaught exceptions to stdout */
136     // System.out.println("--------- UNCAUGHT EXCEPTION ---------");
137
// exception.printStackTrace(System.out);
138
}
139 /**
140  * Initializes connections
141  */

142 /* WARNING: THIS METHOD WILL BE REGENERATED. */
143 private void initConnections() {
144     // user code begin {1}
145
// user code end
146
getCloseButton().addActionListener(this);
147 }
148 /**
149  * Initialize the class.
150  */

151 /* WARNING: THIS METHOD WILL BE REGENERATED. */
152 private void initialize() {
153     // user code begin {1}
154
// user code end
155
setName("CloseButtonPanel");
156     setLayout(getCloseButtonPanelFlowLayout());
157     setBackground(java.awt.SystemColor.control);
158     setSize(427, 34);
159     add(getCloseButton(), getCloseButton().getName());
160     initConnections();
161     // user code begin {2}
162
// user code end
163
}
164 /**
165  * main entrypoint - starts the part when it is run as an application
166  * @param args java.lang.String[]
167  */

168 public static void main(java.lang.String JavaDoc[] args) {
169     try {
170         java.awt.Frame JavaDoc frame;
171         try {
172             Class JavaDoc aFrameClass = Class.forName("com.ibm.uvm.abt.edit.TestFrame");
173             frame = (java.awt.Frame JavaDoc)aFrameClass.newInstance();
174         } catch (java.lang.Throwable JavaDoc ivjExc) {
175             frame = new java.awt.Frame JavaDoc();
176         }
177         CloseButtonPanel aCloseButtonPanel;
178         aCloseButtonPanel = new CloseButtonPanel();
179         frame.add("Center", aCloseButtonPanel);
180         frame.setSize(aCloseButtonPanel.getSize());
181         frame.setVisible(true);
182     } catch (Throwable JavaDoc exception) {
183         System.err.println("Exception occurred in main() of java.awt.Panel");
184         exception.printStackTrace(System.out);
185     }
186 }
187 public void paint(java.awt.Graphics JavaDoc g) {
188     g.setColor(getBackground());
189     g.fill3DRect(0, 0, getBounds().width, getBounds().height, true);
190 }
191
192 }
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
Popular Tags