KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > businesslogic > ireport > gui > locale > NewLocaleFileDialog


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  * NewLocaleFileDialog.java
28  *
29  * Created on 17 novembre 2004, 1.07
30  *
31  */

32
33 package it.businesslogic.ireport.gui.locale;
34 import it.businesslogic.ireport.util.I18n;
35
36 /**
37  *
38  * @author Administrator
39  */

40 public class NewLocaleFileDialog extends javax.swing.JDialog JavaDoc {
41     
42     private int dialogResult = javax.swing.JOptionPane.CANCEL_OPTION;
43     
44     private String JavaDoc text = "";
45     
46     /** Creates new form NewLocaleFileDialog */
47     public NewLocaleFileDialog(java.awt.Dialog JavaDoc parent, boolean modal) {
48         super(parent, modal);
49         initAll();
50     }
51     
52      public NewLocaleFileDialog(java.awt.Frame JavaDoc parent, boolean modal) {
53         super(parent, modal);
54         initAll();
55         
56     }
57      
58      public void initAll()
59      {
60          initComponents();
61          this.setSize(300,100);
62         it.businesslogic.ireport.util.Misc.centerFrame(this);
63          javax.swing.KeyStroke JavaDoc escape = javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0, false);
64         javax.swing.Action JavaDoc escapeAction = new javax.swing.AbstractAction JavaDoc() {
65             public void actionPerformed(java.awt.event.ActionEvent JavaDoc e) {
66                 jButton2ActionPerformed(e);
67             }
68         };
69        
70         getRootPane().getInputMap(javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
71         getRootPane().getActionMap().put("ESCAPE", escapeAction);
72
73         applyI18n();
74         //to make the default button ...
75
this.getRootPane().setDefaultButton(this.jButton1);
76      }
77     
78     public int getDialogResult() {
79         return dialogResult;
80     }
81
82     public void setDialogResult(int dialogResult) {
83         this.dialogResult = dialogResult;
84     }
85     
86     /** This method is called from within the constructor to
87      * initialize the form.
88      * WARNING: Do NOT modify this code. The content of this method is
89      * always regenerated by the Form Editor.
90      */

91     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
92
private void initComponents() {
93         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
94
95         jLabel1 = new javax.swing.JLabel JavaDoc();
96         jTextField1 = new javax.swing.JTextField JavaDoc();
97         jPanel1 = new javax.swing.JPanel JavaDoc();
98         jButton1 = new javax.swing.JButton JavaDoc();
99         jButton2 = new javax.swing.JButton JavaDoc();
100
101         getContentPane().setLayout(new java.awt.GridBagLayout JavaDoc());
102
103         setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
104         jLabel1.setText("Locale suffix (i.e. \"_en_US\"). Blank for default locale");
105         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
106         gridBagConstraints.gridx = 0;
107         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
108         gridBagConstraints.weightx = 1.0;
109         gridBagConstraints.insets = new java.awt.Insets JavaDoc(4, 4, 0, 0);
110         getContentPane().add(jLabel1, gridBagConstraints);
111
112         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
113         gridBagConstraints.gridx = 0;
114         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
115         gridBagConstraints.insets = new java.awt.Insets JavaDoc(2, 4, 4, 4);
116         getContentPane().add(jTextField1, gridBagConstraints);
117
118         jButton1.setText("OK");
119         jButton1.addActionListener(new java.awt.event.ActionListener JavaDoc() {
120             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
121                 jButton1ActionPerformed(evt);
122             }
123         });
124
125         jPanel1.add(jButton1);
126
127         jButton2.setText("Cancel");
128         jButton2.addActionListener(new java.awt.event.ActionListener JavaDoc() {
129             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
130                 jButton2ActionPerformed(evt);
131             }
132         });
133
134         jPanel1.add(jButton2);
135
136         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
137         gridBagConstraints.gridx = 0;
138         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
139         gridBagConstraints.weightx = 1.0;
140         gridBagConstraints.weighty = 1.0;
141         getContentPane().add(jPanel1, gridBagConstraints);
142
143         pack();
144     }// </editor-fold>//GEN-END:initComponents
145

146     private void jButton2ActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButton2ActionPerformed
147
this.setDialogResult( javax.swing.JOptionPane.CANCEL_OPTION);
148         this.setVisible(false);
149         this.dispose();
150     }//GEN-LAST:event_jButton2ActionPerformed
151

152     private void jButton1ActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jButton1ActionPerformed
153
text = jTextField1.getText().trim();
154         this.setDialogResult( javax.swing.JOptionPane.OK_OPTION);
155         this.setVisible(false);
156         this.dispose();
157     }//GEN-LAST:event_jButton1ActionPerformed
158

159
160     public String JavaDoc getText() {
161         return text;
162     }
163
164     public void setText(String JavaDoc text) {
165         this.text = text;
166     }
167     
168     // Variables declaration - do not modify//GEN-BEGIN:variables
169
private javax.swing.JButton JavaDoc jButton1;
170     private javax.swing.JButton JavaDoc jButton2;
171     private javax.swing.JLabel JavaDoc jLabel1;
172     private javax.swing.JPanel JavaDoc jPanel1;
173     private javax.swing.JTextField JavaDoc jTextField1;
174     // End of variables declaration//GEN-END:variables
175

176     public void applyI18n(){
177                 // Start autogenerated code ----------------------
178
jButton1.setText(I18n.getString("newLocaleFileDialog.button1","OK"));
179                 jButton2.setText(I18n.getString("newLocaleFileDialog.button2","Cancel"));
180                 jLabel1.setText(I18n.getString("newLocaleFileDialog.label1","Locale suffix (i.e. \"_en_US\"). Blank for default locale"));
181                 // End autogenerated code ----------------------
182
}
183 }
184
Popular Tags