KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > security > GUIErrorDialog


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * GUIErrorDialog.java
26  * An error dialog box used for FailedLogin
27  *
28  * @author Harpreet Singh
29  * @version
30  */

31
32 package com.sun.enterprise.security;
33 import javax.swing.*;
34 import java.awt.*;
35 import java.awt.event.*;
36
37 public class GUIErrorDialog extends javax.swing.JDialog JavaDoc {
38     String JavaDoc message;
39     /** Creates new form GUIErrorDialog */
40     public GUIErrorDialog (String JavaDoc message){
41     super (new JFrame (), true);
42     this.message = message;
43     initComponents ();
44     pack ();
45     }
46     /** This method is called from within the constructor to
47      * initialize the form.
48      */

49     private void initComponents() {
50         okButton = new javax.swing.JButton JavaDoc();
51         errorLbl = new javax.swing.JLabel JavaDoc();
52     okButton.setAlignmentX (CENTER_ALIGNMENT);
53     errorLbl.setAlignmentX (CENTER_ALIGNMENT);
54     getContentPane().setLayout (new javax.swing.BoxLayout JavaDoc (getContentPane (),BoxLayout.Y_AXIS));
55         addWindowListener(new java.awt.event.WindowAdapter JavaDoc() {
56             public void windowClosing(java.awt.event.WindowEvent JavaDoc evt) {
57                 closeDialog(evt);
58             }
59         }
60         );
61         
62         okButton.setLabel("OK");
63         okButton.setActionCommand("okButton");
64         okButton.setText("OK");
65         okButton.addActionListener (new ActionListener (){
66         public void actionPerformed (ActionEvent e){
67             dispose ();
68         }
69         });
70     super.addWindowListener (new WindowAdapter (){
71         public void windowClosing (WindowEvent we){
72             dispose ();
73         }
74         });
75         errorLbl.setText("Error : "+message);
76     getContentPane().add (errorLbl);
77     getContentPane().add (okButton);
78     }
79
80     /** Closes the dialog */
81     private void closeDialog(java.awt.event.WindowEvent JavaDoc evt) {
82         setVisible (false);
83         dispose ();
84     }
85
86     // Variables declaration - do not modify//GEN-BEGIN:variables
87
private javax.swing.JButton JavaDoc okButton;
88     private javax.swing.JLabel JavaDoc errorLbl;
89     // End of variables declaration//GEN-END:variables
90

91 }
92
Popular Tags