KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > businesslogic > ireport > connection > PasswordDialog


1 /*
2  * Copyright (C) 2005 - 2006 JasperSoft Corporation. All rights reserved.
3  * http://www.jaspersoft.com.
4  *
5  * Unless you have purchased a commercial license agreement from JasperSoft,
6  * the following license terms apply:
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as published by
10  * the Free Software Foundation.
11  *
12  * This program is distributed WITHOUT ANY WARRANTY; and without the
13  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
18  * or write to:
19  *
20  * Free Software Foundation, Inc.,
21  * 59 Temple Place - Suite 330,
22  * Boston, MA USA 02111-1307
23  *
24  *
25  *
26  *
27  * PasswordDialog.java
28  *
29  * Created on 9 maggio 2003, 17.25
30  *
31  */

32
33 package it.businesslogic.ireport.connection;
34
35 import it.businesslogic.ireport.util.*;
36 import it.businesslogic.ireport.*;
37 import java.lang.reflect.InvocationTargetException JavaDoc;
38 import javax.swing.SwingUtilities JavaDoc;
39 /**
40  *
41  * @author Administrator
42  */

43 public class PasswordDialog extends javax.swing.JDialog JavaDoc {
44     /** Creates new form JRParameterDialog */
45     private String JavaDoc password = null;
46     
47     public PasswordDialog(java.awt.Frame JavaDoc parent, boolean modal) {
48         
49         super(parent, modal);
50         initComponents();
51         this.setSize(320, 144);
52         Misc.centerFrame(this);
53         
54         applyI18n();
55         
56         javax.swing.KeyStroke JavaDoc escape = javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0, false);
57         javax.swing.Action JavaDoc escapeAction = new javax.swing.AbstractAction JavaDoc() {
58             public void actionPerformed(java.awt.event.ActionEvent JavaDoc e) {
59                 jButtonCancelActionPerformed(e);
60             }
61         };
62        
63         getRootPane().getInputMap(javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
64         getRootPane().getActionMap().put("ESCAPE", escapeAction);
65
66
67         //to make the default button ...
68
this.getRootPane().setDefaultButton(this.jButtonOK);
69     }
70     /** This method is called from within the constructor to
71      * initialize the form.
72      * WARNING: Do NOT modify this code. The content of this method is
73      * always regenerated by the Form Editor.
74      */

75     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
76
private void initComponents() {
77         jLabel1 = new javax.swing.JLabel JavaDoc();
78         jButtonCancel = new javax.swing.JButton JavaDoc();
79         jButtonOK = new javax.swing.JButton JavaDoc();
80         jPasswordField = new javax.swing.JPasswordField JavaDoc();
81
82         getContentPane().setLayout(null);
83
84         setTitle("Password");
85         setModal(true);
86         setResizable(false);
87         addWindowListener(new java.awt.event.WindowAdapter JavaDoc() {
88             public void windowClosing(java.awt.event.WindowEvent JavaDoc evt) {
89                 closeDialog(evt);
90             }
91         });
92
93         jLabel1.setText("Password:");
94         getContentPane().add(jLabel1);
95         jLabel1.setBounds(4, 4, 250, 14);
96
97         jButtonCancel.setMnemonic('c');
98         jButtonCancel.setText("Cancel");
99         jButtonCancel.addActionListener(new java.awt.event.ActionListener JavaDoc() {
100             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
101                 jButtonCancelActionPerformed(evt);
102             }
103         });
104
105         getContentPane().add(jButtonCancel);
106         jButtonCancel.setBounds(220, 52, 70, 23);
107
108         jButtonOK.setMnemonic('o');
109         jButtonOK.setText("OK");
110         jButtonOK.addActionListener(new java.awt.event.ActionListener JavaDoc() {
111             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
112                 jButtonOKActionPerformed(evt);
113             }
114         });
115
116         getContentPane().add(jButtonOK);
117         jButtonOK.setBounds(138, 52, 70, 23);
118
119         getContentPane().add(jPasswordField);
120         jPasswordField.setBounds(4, 20, 286, 24);
121
122         pack();
123     }// </editor-fold>//GEN-END:initComponents
124

125     private void jButtonCancelActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
126
setVisible(false);
127         this.setDialogResult( javax.swing.JOptionPane.CANCEL_OPTION);
128         dispose();
129     }//GEN-LAST:event_jButtonCancelActionPerformed
130

131     private void jButtonOKActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButtonOKActionPerformed
132

133         try {
134             password = this.jPasswordField.getDocument().getText(0,this.jPasswordField.getDocument().getLength());
135         } catch (Exception JavaDoc ex) {}
136         this.setDialogResult( javax.swing.JOptionPane.OK_OPTION);
137         dispose();
138     }//GEN-LAST:event_jButtonOKActionPerformed
139

140     /** Closes the dialog */
141     private void closeDialog(java.awt.event.WindowEvent JavaDoc evt) {//GEN-FIRST:event_closeDialog
142
setVisible(false);
143         this.setDialogResult( javax.swing.JOptionPane.CLOSED_OPTION);
144         dispose();
145     }//GEN-LAST:event_closeDialog
146

147       /** Getter for property dialogResult.
148      * @return Value of property dialogResult.
149      *
150      */

151     public int getDialogResult() {
152         return dialogResult;
153     }
154     
155     /** Setter for property dialogResult.
156      * @param dialogResult New value of property dialogResult.
157      *
158      */

159     public void setDialogResult(int dialogResult) {
160         this.dialogResult = dialogResult;
161     }
162     
163     /** Getter for property password.
164      * @return Value of property password.
165      *
166      */

167     public java.lang.String JavaDoc getPassword() {
168         return password;
169     }
170     
171     /** Setter for property password.
172      * @param password New value of property password.
173      *
174      */

175     public void setPassword(java.lang.String JavaDoc password) {
176         this.password = password;
177     }
178     
179     // Variables declaration - do not modify//GEN-BEGIN:variables
180
private javax.swing.JButton JavaDoc jButtonCancel;
181     private javax.swing.JButton JavaDoc jButtonOK;
182     private javax.swing.JLabel JavaDoc jLabel1;
183     private javax.swing.JPasswordField JavaDoc jPasswordField;
184     // End of variables declaration//GEN-END:variables
185

186     private int dialogResult;
187     
188     public void applyI18n(){
189                 // Start autogenerated code ----------------------
190
jButtonCancel.setText(I18n.getString("passwordDialog.buttonCancel","Cancel"));
191                 jButtonOK.setText(I18n.getString("passwordDialog.buttonOK","OK"));
192                 jLabel1.setText(I18n.getString("passwordDialog.label1","Password:"));
193                 // End autogenerated code ----------------------
194
}
195     
196     
197 }
198
Popular Tags