01: /*
02: * Project: AMODA - Abstract Modeled Application
03: * Class: de.gulden.framework.amoda.environment.gui.component.JDialogCloseable
04: * Version: snapshot-beautyj-1.1
05: *
06: * Date: 2004-09-29
07: *
08: * This is a snapshot version of the AMODA 0.2 development branch,
09: * it is not released as a seperate version.
10: * For AMODA, see http://amoda.berlios.de/.
11: *
12: * This is licensed under the GNU Lesser General Public License (LGPL)
13: * and comes with NO WARRANTY.
14: *
15: * Author: Jens Gulden
16: * Email: amoda@jensgulden.de
17: */
18:
19: package de.gulden.framework.amoda.environment.gui.component;
20:
21: import java.awt.Container;
22: import javax.swing.*;
23:
24: /**
25: * Class JDialogCloseable.
26: *
27: * @author Jens Gulden
28: * @version snapshot-beautyj-1.1
29: */
30: public class JDialogCloseable extends JDialog {
31:
32: // ------------------------------------------------------------------------
33: // --- fields ---
34: // ------------------------------------------------------------------------
35:
36: private JPanel buttonPanel;
37:
38: private JButton closeButton;
39:
40: // ------------------------------------------------------------------------
41: // --- constructor ---
42: // ------------------------------------------------------------------------
43:
44: public JDialogCloseable(JFrame frame, String title, boolean modal) {
45: super (frame, title, modal);
46: initComponents();
47: }
48:
49: // ------------------------------------------------------------------------
50: // --- methods ---
51: // ------------------------------------------------------------------------
52:
53: private void initComponents() {
54: //GEN-BEGIN:initComponents
55: buttonPanel = new javax.swing.JPanel();
56: closeButton = new javax.swing.JButton();
57:
58: addWindowListener(new java.awt.event.WindowAdapter() {
59: public void windowClosing(java.awt.event.WindowEvent evt) {
60: exitForm(evt);
61: }
62: });
63:
64: closeButton.setFont(new java.awt.Font("Dialog", 0, 12));
65: closeButton.setText(" OK ");
66: closeButton
67: .addActionListener(new java.awt.event.ActionListener() {
68: public void actionPerformed(
69: java.awt.event.ActionEvent evt) {
70: closeButtonActionPerformed(evt);
71: }
72: });
73:
74: buttonPanel.add(closeButton);
75:
76: getContentPane().add(buttonPanel, java.awt.BorderLayout.SOUTH);
77:
78: pack();
79: }
80:
81: private void closeButtonActionPerformed(
82: java.awt.event.ActionEvent evt) {
83: //GEN-FIRST:event_closeButtonActionPerformed
84: this .setVisible(false);
85: }
86:
87: private void exitForm(java.awt.event.WindowEvent evt) {
88: //GEN-FIRST:event_exitForm
89: closeButtonActionPerformed(null);
90: }
91:
92: } // end JDialogCloseable
|