001: package org.jacorb.poa.gui.beans;
002:
003: /*
004: * JacORB - a free Java ORB
005: *
006: * Copyright (C) 1997-2004 Gerald Brose.
007: *
008: * This library is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU Library General Public
010: * License as published by the Free Software Foundation; either
011: * version 2 of the License, or (at your option) any later version.
012: *
013: * This library is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * Library General Public License for more details.
017: *
018: * You should have received a copy of the GNU Library General Public
019: * License along with this library; if not, write to the Free
020: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021: */
022:
023: /**
024: * Panel with a Close Button
025: *
026: * @author Reimo Tiedemann, FU Berlin
027: * @version 1.01, 05/10/99
028: */
029: public class CloseButtonPanel extends java.awt.Panel implements
030: java.awt.event.ActionListener {
031: private CloseButtonPanelController controller = null;
032: private String buttonLabel = "Close";
033: private java.awt.FlowLayout ivjCloseButtonPanelFlowLayout = null;
034: private java.awt.Button ivjCloseButton = null;
035:
036: /**
037: * Constructor
038: */
039: /* WARNING: THIS METHOD WILL BE REGENERATED. */
040: public CloseButtonPanel() {
041: super ();
042: initialize();
043: }
044:
045: /**
046: * CloseButtonPanel constructor comment.
047: * @param layout java.awt.LayoutManager
048: */
049: public CloseButtonPanel(java.awt.LayoutManager layout) {
050: super (layout);
051: }
052:
053: private void _actionCloseButtonPressed() {
054: if (controller != null) {
055: controller._actionCloseButtonPressed();
056: }
057: }
058:
059: public void _init(CloseButtonPanelController _controller,
060: String _buttonLabel) {
061: controller = _controller;
062: buttonLabel = _buttonLabel;
063: getCloseButton().setLabel(" " + buttonLabel + " ");
064: }
065:
066: /**
067: * Method to handle events for the ActionListener interface.
068: * @param e java.awt.event.ActionEvent
069: */
070: /* WARNING: THIS METHOD WILL BE REGENERATED. */
071: public void actionPerformed(java.awt.event.ActionEvent e) {
072: // user code begin {1}
073: // user code end
074: if ((e.getSource() == getCloseButton())) {
075: connEtoC1(e);
076: }
077: // user code begin {2}
078: // user code end
079: }
080:
081: /**
082: * connEtoC1: (Button1.action.actionPerformed(java.awt.event.ActionEvent) --> CloseButtonPanel._actionCloseButtonPressed()V)
083: * @param arg1 java.awt.event.ActionEvent
084: */
085: /* WARNING: THIS METHOD WILL BE REGENERATED. */
086: private void connEtoC1(java.awt.event.ActionEvent arg1) {
087: try {
088: // user code begin {1}
089: // user code end
090: this ._actionCloseButtonPressed();
091: // user code begin {2}
092: // user code end
093: } catch (java.lang.Throwable ivjExc) {
094: // user code begin {3}
095: // user code end
096: handleException(ivjExc);
097: }
098: }
099:
100: /**
101: * Return the Button1 property value.
102: * @return java.awt.Button
103: */
104: /* WARNING: THIS METHOD WILL BE REGENERATED. */
105: private java.awt.Button getCloseButton() {
106: if (ivjCloseButton == null) {
107: try {
108: ivjCloseButton = new java.awt.Button();
109: ivjCloseButton.setName("CloseButton");
110: ivjCloseButton.setLabel(" Close ");
111: // user code begin {1}
112: // user code end
113: } catch (java.lang.Throwable ivjExc) {
114: // user code begin {2}
115: // user code end
116: handleException(ivjExc);
117: }
118: }
119: ;
120: return ivjCloseButton;
121: }
122:
123: /**
124: * Return the CloseButtonPanelFlowLayout property value.
125: * @return java.awt.FlowLayout
126: */
127: /* WARNING: THIS METHOD WILL BE REGENERATED. */
128: private java.awt.FlowLayout getCloseButtonPanelFlowLayout() {
129: java.awt.FlowLayout ivjCloseButtonPanelFlowLayout = null;
130: try {
131: /* Create part */
132: ivjCloseButtonPanelFlowLayout = new java.awt.FlowLayout();
133: ivjCloseButtonPanelFlowLayout
134: .setAlignment(java.awt.FlowLayout.RIGHT);
135: ivjCloseButtonPanelFlowLayout.setHgap(10);
136: } catch (java.lang.Throwable ivjExc) {
137: handleException(ivjExc);
138: }
139: ;
140: return ivjCloseButtonPanelFlowLayout;
141: }
142:
143: /**
144: * Called whenever the part throws an exception.
145: * @param exception java.lang.Throwable
146: */
147: private void handleException(Throwable exception) {
148:
149: /* Uncomment the following lines to print uncaught exceptions to stdout */
150: // System.out.println("--------- UNCAUGHT EXCEPTION ---------");
151: // exception.printStackTrace(System.out);
152: }
153:
154: /**
155: * Initializes connections
156: */
157: /* WARNING: THIS METHOD WILL BE REGENERATED. */
158: private void initConnections() {
159: // user code begin {1}
160: // user code end
161: getCloseButton().addActionListener(this );
162: }
163:
164: /**
165: * Initialize the class.
166: */
167: /* WARNING: THIS METHOD WILL BE REGENERATED. */
168: private void initialize() {
169: // user code begin {1}
170: // user code end
171: setName("CloseButtonPanel");
172: setLayout(getCloseButtonPanelFlowLayout());
173: setBackground(java.awt.SystemColor.control);
174: setSize(427, 34);
175: add(getCloseButton(), getCloseButton().getName());
176: initConnections();
177: // user code begin {2}
178: // user code end
179: }
180:
181: /**
182: * main entrypoint - starts the part when it is run as an application
183: * @param args java.lang.String[]
184: */
185: public static void main(java.lang.String[] args) {
186: try {
187: java.awt.Frame frame;
188: try {
189: Class aFrameClass = Class
190: .forName("com.ibm.uvm.abt.edit.TestFrame");
191: frame = (java.awt.Frame) aFrameClass.newInstance();
192: } catch (java.lang.Throwable ivjExc) {
193: frame = new java.awt.Frame();
194: }
195: CloseButtonPanel aCloseButtonPanel;
196: aCloseButtonPanel = new CloseButtonPanel();
197: frame.add("Center", aCloseButtonPanel);
198: frame.setSize(aCloseButtonPanel.getSize());
199: frame.setVisible(true);
200: } catch (Throwable exception) {
201: System.err
202: .println("Exception occurred in main() of java.awt.Panel");
203: exception.printStackTrace(System.out);
204: }
205: }
206:
207: public void paint(java.awt.Graphics g) {
208: g.setColor(getBackground());
209: g.fill3DRect(0, 0, getBounds().width, getBounds().height, true);
210: }
211:
212: }
|