KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > gulden > framework > amoda > environment > gui > component > JDialogCloseable


1 /*
2  * Project: AMODA - Abstract Modeled Application
3  * Class: de.gulden.framework.amoda.environment.gui.component.JDialogCloseable
4  * Version: snapshot-beautyj-1.1
5  *
6  * Date: 2004-09-29
7  *
8  * This is a snapshot version of the AMODA 0.2 development branch,
9  * 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 JavaDoc;
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     // ------------------------------------------------------------------------
42
// --- constructor ---
43
// ------------------------------------------------------------------------
44

45     public JDialogCloseable(JFrame frame, String JavaDoc title, boolean modal) {
46         super(frame, title, modal);
47         initComponents();
48     }
49
50
51     // ------------------------------------------------------------------------
52
// --- methods ---
53
// ------------------------------------------------------------------------
54

55     private void initComponents() {
56         //GEN-BEGIN:initComponents
57
buttonPanel = new javax.swing.JPanel JavaDoc();
58                 closeButton = new javax.swing.JButton JavaDoc();
59
60                 addWindowListener(new java.awt.event.WindowAdapter JavaDoc() {
61                     public void windowClosing(java.awt.event.WindowEvent JavaDoc evt) {
62                         exitForm(evt);
63                     }
64                 });
65
66                 closeButton.setFont(new java.awt.Font JavaDoc("Dialog", 0, 12));
67                 closeButton.setText(" OK ");
68                 closeButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
69                     public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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(java.awt.event.ActionEvent JavaDoc evt) {
82         //GEN-FIRST:event_closeButtonActionPerformed
83
this.setVisible(false);
84     }
85
86     private void exitForm(java.awt.event.WindowEvent JavaDoc evt) {
87         //GEN-FIRST:event_exitForm
88
closeButtonActionPerformed(null);
89     }
90
91 } // end JDialogCloseable
92
Popular Tags