001: /*
002: * Copyright (C) 2005 - 2008 JasperSoft Corporation. All rights reserved.
003: * http://www.jaspersoft.com.
004: *
005: * Unless you have purchased a commercial license agreement from JasperSoft,
006: * the following license terms apply:
007: *
008: * This program is free software; you can redistribute it and/or modify
009: * it under the terms of the GNU General Public License version 2 as published by
010: * the Free Software Foundation.
011: *
012: * This program is distributed WITHOUT ANY WARRANTY; and without the
013: * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
014: * See the GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
018: * or write to:
019: *
020: * Free Software Foundation, Inc.,
021: * 59 Temple Place - Suite 330,
022: * Boston, MA USA 02111-1307
023: *
024: *
025: *
026: *
027: * NewLocaleFileDialog.java
028: *
029: * Created on 17 novembre 2004, 1.07
030: *
031: */
032:
033: package it.businesslogic.ireport.gui.locale;
034:
035: import it.businesslogic.ireport.util.I18n;
036:
037: /**
038: *
039: * @author Administrator
040: */
041: public class NewLocaleFileDialog extends javax.swing.JDialog {
042:
043: private int dialogResult = javax.swing.JOptionPane.CANCEL_OPTION;
044:
045: private String text = "";
046:
047: /** Creates new form NewLocaleFileDialog */
048: public NewLocaleFileDialog(java.awt.Dialog parent, boolean modal) {
049: super (parent, modal);
050: initAll();
051: }
052:
053: public NewLocaleFileDialog(java.awt.Frame parent, boolean modal) {
054: super (parent, modal);
055: initAll();
056:
057: }
058:
059: public void initAll() {
060: initComponents();
061: this .setSize(300, 100);
062: it.businesslogic.ireport.util.Misc.centerFrame(this );
063: javax.swing.KeyStroke escape = javax.swing.KeyStroke
064: .getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0,
065: false);
066: javax.swing.Action escapeAction = new javax.swing.AbstractAction() {
067: public void actionPerformed(java.awt.event.ActionEvent e) {
068: jButton2ActionPerformed(e);
069: }
070: };
071:
072: getRootPane().getInputMap(
073: javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(
074: escape, "ESCAPE");
075: getRootPane().getActionMap().put("ESCAPE", escapeAction);
076:
077: applyI18n();
078: //to make the default button ...
079: this .getRootPane().setDefaultButton(this .jButton1);
080: }
081:
082: public int getDialogResult() {
083: return dialogResult;
084: }
085:
086: public void setDialogResult(int dialogResult) {
087: this .dialogResult = dialogResult;
088: }
089:
090: /** This method is called from within the constructor to
091: * initialize the form.
092: * WARNING: Do NOT modify this code. The content of this method is
093: * always regenerated by the Form Editor.
094: */
095: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
096: private void initComponents() {
097: java.awt.GridBagConstraints gridBagConstraints;
098:
099: jLabel1 = new javax.swing.JLabel();
100: jTextField1 = new javax.swing.JTextField();
101: jPanel1 = new javax.swing.JPanel();
102: jButton1 = new javax.swing.JButton();
103: jButton2 = new javax.swing.JButton();
104:
105: getContentPane().setLayout(new java.awt.GridBagLayout());
106:
107: setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
108: jLabel1
109: .setText("Locale suffix (i.e. \"_en_US\"). Blank for default locale");
110: gridBagConstraints = new java.awt.GridBagConstraints();
111: gridBagConstraints.gridx = 0;
112: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
113: gridBagConstraints.weightx = 1.0;
114: gridBagConstraints.insets = new java.awt.Insets(4, 4, 0, 0);
115: getContentPane().add(jLabel1, gridBagConstraints);
116:
117: gridBagConstraints = new java.awt.GridBagConstraints();
118: gridBagConstraints.gridx = 0;
119: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
120: gridBagConstraints.insets = new java.awt.Insets(2, 4, 4, 4);
121: getContentPane().add(jTextField1, gridBagConstraints);
122:
123: jButton1.setText("OK");
124: jButton1.addActionListener(new java.awt.event.ActionListener() {
125: public void actionPerformed(java.awt.event.ActionEvent evt) {
126: jButton1ActionPerformed(evt);
127: }
128: });
129:
130: jPanel1.add(jButton1);
131:
132: jButton2.setText("Cancel");
133: jButton2.addActionListener(new java.awt.event.ActionListener() {
134: public void actionPerformed(java.awt.event.ActionEvent evt) {
135: jButton2ActionPerformed(evt);
136: }
137: });
138:
139: jPanel1.add(jButton2);
140:
141: gridBagConstraints = new java.awt.GridBagConstraints();
142: gridBagConstraints.gridx = 0;
143: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
144: gridBagConstraints.weightx = 1.0;
145: gridBagConstraints.weighty = 1.0;
146: getContentPane().add(jPanel1, gridBagConstraints);
147:
148: pack();
149: }// </editor-fold>//GEN-END:initComponents
150:
151: private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
152: this .setDialogResult(javax.swing.JOptionPane.CANCEL_OPTION);
153: this .setVisible(false);
154: this .dispose();
155: }//GEN-LAST:event_jButton2ActionPerformed
156:
157: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
158: text = jTextField1.getText().trim();
159: this .setDialogResult(javax.swing.JOptionPane.OK_OPTION);
160: this .setVisible(false);
161: this .dispose();
162: }//GEN-LAST:event_jButton1ActionPerformed
163:
164: public String getText() {
165: return text;
166: }
167:
168: public void setText(String text) {
169: this .text = text;
170: }
171:
172: // Variables declaration - do not modify//GEN-BEGIN:variables
173: private javax.swing.JButton jButton1;
174: private javax.swing.JButton jButton2;
175: private javax.swing.JLabel jLabel1;
176: private javax.swing.JPanel jPanel1;
177: private javax.swing.JTextField jTextField1;
178:
179: // End of variables declaration//GEN-END:variables
180:
181: public void applyI18n() {
182: // Start autogenerated code ----------------------
183: jButton1.setText(I18n.getString("newLocaleFileDialog.button1",
184: "OK"));
185: jButton2.setText(I18n.getString("newLocaleFileDialog.button2",
186: "Cancel"));
187: jLabel1
188: .setText(I18n
189: .getString("newLocaleFileDialog.label1",
190: "Locale suffix (i.e. \"_en_US\"). Blank for default locale"));
191: // End autogenerated code ----------------------
192: jButton1.setMnemonic(I18n.getString(
193: "newLocaleFileDialog.button1Mnemonic", "o").charAt(0));
194: jButton2.setMnemonic(I18n.getString(
195: "newLocaleFileDialog.button2Mnemonic", "c").charAt(0));
196: }
197: }
|