0001: /*
0002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0003: *
0004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
0005: *
0006: * The contents of this file are subject to the terms of either the GNU
0007: * General Public License Version 2 only ("GPL") or the Common
0008: * Development and Distribution License("CDDL") (collectively, the
0009: * "License"). You may not use this file except in compliance with the
0010: * License. You can obtain a copy of the License at
0011: * http://www.netbeans.org/cddl-gplv2.html
0012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
0013: * specific language governing permissions and limitations under the
0014: * License. When distributing the software, include this License Header
0015: * Notice in each file and include the License file at
0016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
0017: * particular file as subject to the "Classpath" exception as provided
0018: * by Sun in the GPL Version 2 section of the License file that
0019: * accompanied this code. If applicable, add the following below the
0020: * License Header, with the fields enclosed by brackets [] replaced by
0021: * your own identifying information:
0022: * "Portions Copyrighted [year] [name of copyright owner]"
0023: *
0024: * Contributor(s):
0025: *
0026: * The Original Software is NetBeans. The Initial Developer of the Original
0027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
0028: * Microsystems, Inc. All Rights Reserved.
0029: *
0030: * If you wish your version of this file to be governed by only the CDDL
0031: * or only the GPL Version 2, indicate your decision by adding
0032: * "[Contributor] elects to include this software in this distribution
0033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
0034: * single choice of license, a recipient has the option to distribute
0035: * your version of this file under either the CDDL, the GPL Version 2 or
0036: * to extend the choice of license to its licensees as provided above.
0037: * However, if you add GPL Version 2 code and therefore, elected the GPL
0038: * Version 2 license, then the option applies only if the new code is
0039: * made subject to such option by the copyright holder.
0040: */
0041: package org.netbeans.modules.visualweb.faces.dt.converter;
0042:
0043: import com.sun.rave.designtime.DesignBean;
0044: import com.sun.rave.designtime.DesignProperty;
0045: import org.netbeans.modules.visualweb.faces.dt.util.ComponentBundle;
0046: import java.awt.event.FocusAdapter;
0047: import java.text.DecimalFormat;
0048: import java.text.DecimalFormatSymbols;
0049: import java.text.NumberFormat;
0050: import java.util.ArrayList;
0051: import java.util.Arrays;
0052: import java.util.Currency;
0053: import java.util.Locale;
0054: import javax.swing.JTextField;
0055: import org.openide.DialogDisplayer;
0056: import org.openide.NotifyDescriptor;
0057: import org.openide.util.NbBundle;
0058:
0059: /*
0060: * NumberConverterCustomizerPanel.java
0061: *
0062: * Created on September 14, 2005, 5:53 PM
0063: */
0064:
0065: /**
0066: * A panel for customizing the NumberConverter
0067: *
0068: * @author jhoff, dongmei, gowri
0069: */
0070: public class NumberConverterCustomizerPanel extends javax.swing.JPanel {
0071:
0072: private static final ComponentBundle bundle = ComponentBundle
0073: .getBundle(NumberConverterCustomizerPanel.class); // Used for Internationalizatio
0074:
0075: protected DesignProperty prop;
0076: protected DesignBean designBean;
0077:
0078: private Locale[] locales;
0079:
0080: // Supported types: number, currency, percent
0081: private static final String[] typeValues = { "number", "currency",
0082: "percent" }; // NOI18N
0083: private static final String[] typeDisplayNames = {
0084: NbBundle.getMessage(NumberConverterCustomizerPanel.class,
0085: "number"),
0086: NbBundle.getMessage(NumberConverterCustomizerPanel.class,
0087: "currency"),
0088: NbBundle.getMessage(NumberConverterCustomizerPanel.class,
0089: "percent") };
0090:
0091: public NumberConverterCustomizerPanel(DesignBean designBean) {
0092:
0093: this .designBean = designBean;
0094: String[] localeDisplayNames = getLocaleDisplayNames();
0095:
0096: // Initialize all the components in the panel
0097: initComponents();
0098:
0099: // Populate the pattern combo box with some sample patterns
0100: NumberFormat form1, form2, form3, form4;
0101: form1 = NumberFormat.getInstance();
0102: form2 = NumberFormat.getIntegerInstance();
0103: form3 = NumberFormat.getCurrencyInstance();
0104: form4 = NumberFormat.getPercentInstance();
0105: cmbPattern.setModel(new javax.swing.DefaultComboBoxModel(
0106: new String[] { "", ((DecimalFormat) form1).toPattern(),
0107: ((DecimalFormat) form2).toPattern(),
0108: ((DecimalFormat) form3).toPattern(),
0109: ((DecimalFormat) form4).toPattern() }));
0110:
0111: // Type combo box - Number, Currency, Percent
0112: cmbType.setModel(new javax.swing.DefaultComboBoxModel(
0113: typeDisplayNames));
0114:
0115: // Populate the locale combo box
0116: cmbLocale.setModel(new javax.swing.DefaultComboBoxModel(
0117: localeDisplayNames));
0118:
0119: // Populate the currency code
0120: cmbCurrencyCode.setModel(new javax.swing.DefaultComboBoxModel(
0121: ISO4217CurrencyCode.getDisplayNames()));
0122:
0123: // The Min/Max integer digits, Min/Max fractional digits
0124: String[] digitsArray = new String[] { "", "0", "1", "2", "3",
0125: "4", "5", "6", "7", "8", "9", "10", "30", "40", "50" };
0126: cmbMinInteger.setModel(new javax.swing.DefaultComboBoxModel(
0127: digitsArray));
0128: cmbMaxInteger.setModel(new javax.swing.DefaultComboBoxModel(
0129: digitsArray));
0130: cmbMinFractional.setModel(new javax.swing.DefaultComboBoxModel(
0131: digitsArray));
0132: cmbMaxFractional.setModel(new javax.swing.DefaultComboBoxModel(
0133: digitsArray));
0134: ((JTextField) cmbMinInteger.getEditor().getEditorComponent())
0135: .setHorizontalAlignment(JTextField.RIGHT);
0136: ((JTextField) cmbMaxInteger.getEditor().getEditorComponent())
0137: .setHorizontalAlignment(JTextField.RIGHT);
0138: ((JTextField) cmbMinFractional.getEditor().getEditorComponent())
0139: .setHorizontalAlignment(JTextField.RIGHT);
0140: ((JTextField) cmbMaxFractional.getEditor().getEditorComponent())
0141: .setHorizontalAlignment(JTextField.RIGHT);
0142:
0143: // Fill in the panel with the values from the designBean
0144: fillPanel();
0145:
0146: // The Example part of the panel
0147: cmbExample.setModel(new javax.swing.DefaultComboBoxModel(
0148: new String[] { "1234.56", "-1234.56", "123.4567",
0149: "0.123", "01234" }));
0150:
0151: cmbExample.getEditor().getEditorComponent().addFocusListener(
0152: new FocusAdapter() {
0153: public void focusGained(
0154: java.awt.event.FocusEvent evt) {
0155: cmbExampleFocusGained(evt);
0156: }
0157:
0158: public void focusLost(java.awt.event.FocusEvent evt) {
0159: cmbExampleFocusLost(evt);
0160: }
0161: });
0162: }
0163:
0164: // Called by the Customizer
0165: public boolean isModified() {
0166: // TODO return true for now always
0167: return true;
0168: }
0169:
0170: /**
0171: * This method is called by the Customizer to get the customized values
0172: */
0173: public void customizerApply() {
0174:
0175: // Valid the user inputs first
0176: if (!validateUserInput())
0177: return;
0178:
0179: // Now, set the user inputs to the design bean
0180:
0181: DesignProperty prop = null;
0182:
0183: if (rbType.isSelected()) {
0184: // Type is selected
0185: prop = designBean.getProperty("type"); //NOI18N
0186: prop.setValue(typeValues[cmbType.getSelectedIndex()]);
0187:
0188: prop = designBean.getProperty("minIntegerDigits"); //NOI18N
0189: Integer minInt = getInteger((String) cmbMinInteger
0190: .getSelectedItem());
0191: if (minInt != null)
0192: prop.setValue(minInt);
0193: else
0194: prop.unset();
0195:
0196: prop = designBean.getProperty("maxIntegerDigits"); //NOI18N
0197: Integer maxInt = getInteger((String) cmbMaxInteger
0198: .getSelectedItem());
0199: if (maxInt != null)
0200: prop.setValue(maxInt);
0201: else
0202: prop.unset();
0203:
0204: prop = designBean.getProperty("minFractionDigits"); //NOI18N
0205: Integer minFrac = getInteger((String) cmbMinFractional
0206: .getSelectedItem());
0207: if (minFrac != null)
0208: prop.setValue(minFrac);
0209: else
0210: prop.unset();
0211:
0212: prop = designBean.getProperty("maxFractionDigits"); //NOI18N
0213: Integer maxFrac = getInteger((String) cmbMaxFractional
0214: .getSelectedItem());
0215: if (maxFrac != null)
0216: prop.setValue(maxFrac);
0217: else
0218: prop.unset();
0219:
0220: prop = designBean.getProperty("groupingUsed"); //NOI18N
0221: prop.setValue(new Boolean(cbUseGrouping.isSelected()));
0222:
0223: prop = designBean.getProperty("locale"); //NOI18N
0224: Locale selectedLocale = getLocaleBasedOnComboBoxIndex(cmbLocale
0225: .getSelectedIndex());
0226: if (selectedLocale == null)
0227: prop.unset();
0228: else
0229: prop.setValue(selectedLocale);
0230:
0231: if (cmbType.getSelectedIndex() == 1) { // currency
0232: if (rbSymbol.isSelected()) {
0233: String currencySymbol = txtEnterSymbol.getText()
0234: .trim();
0235:
0236: designBean.getProperty("currencySymbol").setValue(
0237: currencySymbol); //NOI18N
0238: designBean.getProperty("currencyCode").unset(); //NOI18N
0239:
0240: } else {
0241: String currencyCode = null;
0242:
0243: // If there is only one item in the combo box, then we can use the
0244: // selected locale the figure out the currency code
0245: if (cmbCurrencyCode.getModel().getSize() == 1) {
0246: currencyCode = Currency.getInstance(
0247: selectedLocale).getCurrencyCode();
0248: } else {
0249: //
0250: int index = cmbCurrencyCode.getSelectedIndex();
0251: currencyCode = ISO4217CurrencyCode
0252: .getCode(index);
0253: }
0254:
0255: designBean.getProperty("currencyCode").setValue(
0256: currencyCode); //NOI18N
0257: designBean.getProperty("currencySymbol").unset(); //NOI18N
0258: }
0259: } else {
0260: designBean.getProperty("currencyCode").unset();
0261: designBean.getProperty("currencySymbol").unset();
0262: }
0263:
0264: // Unset the pattern
0265: designBean.getProperty("pattern").unset();
0266:
0267: } else {
0268: // Pattern is used
0269: prop = designBean.getProperty("pattern"); //NOI18N
0270: prop.setValue(cmbPattern.getSelectedItem());
0271:
0272: // Unset the type related props
0273: designBean.getProperty("type").unset();
0274: designBean.getProperty("minIntegerDigits").unset();
0275: designBean.getProperty("maxIntegerDigits").unset();
0276: designBean.getProperty("minFractionDigits").unset();
0277: designBean.getProperty("maxFractionDigits").unset();
0278: designBean.getProperty("groupingUsed").unset();
0279: designBean.getProperty("currencyCode").unset();
0280: designBean.getProperty("currencySymbol").unset();
0281: designBean.getProperty("locale").unset();
0282: }
0283:
0284: // Integer Only applies to both Type and Pattern
0285: prop = designBean.getProperty("integerOnly"); //NOI18N
0286: prop.setValue(new Boolean(cbIntegerOnly.isSelected()));
0287: }
0288:
0289: private Locale getLocaleBasedOnComboBoxIndex(int index) {
0290: // Since in the locale combo box, the first item is blank,
0291: // we need to adjust the index by 1 to the locale object
0292:
0293: if (index == 0)
0294: return null;
0295: else
0296: return locales[index - 1];
0297: }
0298:
0299: private Integer getInteger(String integerStr) {
0300: if (integerStr != null && integerStr.trim().length() != 0) {
0301: int intNum = Integer.parseInt(integerStr.trim());
0302: return new Integer(intNum);
0303: } else
0304: return null;
0305: }
0306:
0307: // Get the display names for all the available locales
0308: private String[] getLocaleDisplayNames() {
0309: locales = Locale.getAvailableLocales();
0310:
0311: // Sort the locales based on the display names
0312: Arrays.sort(locales, new LocaleComparator());
0313:
0314: String[] displayNames = new String[locales.length + 1];
0315: ArrayList currencyCodes = new ArrayList();
0316:
0317: // The first only is blank
0318: displayNames[0] = "";
0319:
0320: for (int i = 0; i < locales.length; i++) {
0321: displayNames[i + 1] = locales[i].getDisplayName();
0322: }
0323:
0324: return displayNames;
0325: }
0326:
0327: class LocaleComparator implements java.util.Comparator<Locale> {
0328:
0329: public int compare(Locale locale1, Locale locale2) {
0330: return locale1.getDisplayName().compareTo(
0331: locale2.getDisplayName());
0332: }
0333: }
0334:
0335: // Fill the panel with values from the design bean
0336: private void fillPanel() {
0337:
0338: DesignProperty prop = null;
0339:
0340: // Make sure the check is based on pattern, not type
0341: // Must be some bug from insync. The type is always set no matter what
0342: prop = designBean.getProperty("pattern"); //NOI18N
0343: if (prop.getValue() != null
0344: && ((String) prop.getValue()).trim().length() != 0) {
0345: // Pattern is used, then fill in the Pattern part of the panel
0346: rbPattern.setSelected(true);
0347: rbType.setSelected(false);
0348: prop = designBean.getProperty("pattern"); //NOI18N
0349: cmbPattern.setSelectedItem((String) prop.getValue());
0350: } else {
0351: /// Type is selected
0352: rbType.setSelected(true);
0353: rbPattern.setSelected(false);
0354: }
0355:
0356: // Fill in the type part of the panel
0357: fillTypePanel();
0358:
0359: // Integer Only applies to both Type and Pattern
0360: prop = designBean.getProperty("integerOnly"); //NOI18N
0361: Boolean bool = (Boolean) (prop.getValue());
0362: cbIntegerOnly.setSelected(bool.booleanValue());
0363:
0364: // Enable/disable the components based on what is selected
0365: enableTypePanel();
0366: enablePatternPanel();
0367: }
0368:
0369: // Fill in the type part of the panel. It is called when the type is selected
0370: private void fillTypePanel() {
0371:
0372: DesignProperty prop = null;
0373:
0374: // Which type is selected? Number? Currency? Or Percent
0375: String type = (String) designBean.getProperty("type")
0376: .getValue();
0377: int typeIndex = getTypeIndex(type);
0378: cmbType.setSelectedIndex(typeIndex);
0379:
0380: // Min/Max Integer Digits and Min/Max Fractional Digits
0381: Integer minInteger = (Integer) designBean.getProperty(
0382: "minIntegerDigits").getValue(); //NOI18N
0383: cmbMinInteger.setSelectedItem(minInteger.toString());
0384:
0385: Integer maxInteger = (Integer) designBean.getProperty(
0386: "maxIntegerDigits").getValue(); //NOI18N
0387: cmbMaxInteger.setSelectedItem(maxInteger.toString());
0388:
0389: Integer minFractional = (Integer) designBean.getProperty(
0390: "minFractionDigits").getValue(); //NOI18N
0391: cmbMinFractional.setSelectedItem(minFractional.toString());
0392:
0393: Integer maxFractional = (Integer) designBean.getProperty(
0394: "maxFractionDigits").getValue(); //NOI18N
0395: cmbMaxFractional.setSelectedItem(maxFractional.toString());
0396:
0397: // Use Grouping Separator
0398: Boolean groupingUsed = (Boolean) designBean.getProperty(
0399: "groupingUsed").getValue(); // NOI18N
0400: cbUseGrouping.setSelected(groupingUsed.booleanValue());
0401:
0402: // Which Locale is selected
0403: Locale locale = (Locale) designBean.getProperty("locale")
0404: .getValue(); //NOI18N
0405: if (locale == null)
0406: locale = Locale.getDefault();
0407:
0408: cmbLocale.setSelectedItem(locale.getDisplayName());
0409:
0410: // Fill in the currency symbol and code if possible
0411: if (typeIndex == 1) { // currency
0412: String currencyCode = (String) designBean.getProperty(
0413: "currencyCode").getValue();
0414: String currencySymbol = (String) designBean.getProperty(
0415: "currencySymbol").getValue();
0416: if (currencyCode != null) {
0417: rbCurrencyCode.setSelected(true);
0418: cmbCurrencyCode.setSelectedItem(ISO4217CurrencyCode
0419: .getDisplayName(currencyCode));
0420: } else {
0421: rbSymbol.setSelected(true);
0422: txtEnterSymbol.setText(currencySymbol);
0423: }
0424: } else {
0425: // Fill in the symbol based on the locale selected
0426: try {
0427: Currency cur = Currency.getInstance(locale);
0428: cmbCurrencyCode.setSelectedItem(ISO4217CurrencyCode
0429: .getDisplayName(cur.getCurrencyCode()));
0430: txtEnterSymbol.setText(cur.getSymbol());
0431: } catch (IllegalArgumentException ie) {
0432: // Happens if the locale does not have right country code
0433: // Then just use the defaults
0434: }
0435:
0436: // Have the currency code radio button selected by default
0437: rbCurrencyCode.setSelected(true);
0438: rbSymbol.setSelected(false);
0439: }
0440:
0441: }
0442:
0443: private int getTypeIndex(String typeValue) {
0444: if (typeValue.equals(typeValues[0])) {
0445: return 0;
0446: } else if (typeValue.equals(typeValues[1])) {
0447: return 1;
0448: } else if (typeValue.equals(typeValues[2])) {
0449: return 2;
0450: } else
0451: return 0;
0452: }
0453:
0454: // Validate the user entered values
0455: // This method will be called in customizerApply() when "Apply" is clicked and upateTestResult() when "Test" and
0456: // a new sample number is entered/selected
0457: private boolean validateUserInput() {
0458: boolean valid = true;
0459: StringBuffer msg = new StringBuffer();
0460:
0461: if (rbType.isSelected()) {
0462: // First, make sure Min/Max integer/fractional digits are numbers (>=0)
0463: // Default min/max integer digits are 1/40 and min/max fractional digits are 0/3 if they are not set
0464:
0465: String numStr = null;
0466: int minInteger = 0, maxInteger = 0, minFractional = 0, maxFractional = 0;
0467: try {
0468: numStr = (String) cmbMinInteger.getSelectedItem();
0469: if (numStr != null && numStr.trim().length() != 0)
0470: minInteger = Integer.parseInt(numStr);
0471: else
0472: minInteger = 1;
0473: } catch (NumberFormatException ne) {
0474: valid = false;
0475: msg.append(NbBundle.getMessage(
0476: NumberConverterCustomizerPanel.class,
0477: "badMinIntegerDigits"));
0478: }
0479:
0480: try {
0481: numStr = (String) cmbMaxInteger.getSelectedItem();
0482: if (numStr != null && numStr.trim().length() != 0)
0483: maxInteger = Integer.parseInt(numStr);
0484: else
0485: maxInteger = 40;
0486: } catch (NumberFormatException ne) {
0487: valid = false;
0488: msg.append(NbBundle.getMessage(
0489: NumberConverterCustomizerPanel.class,
0490: "badMaxIntegerDigits"));
0491: }
0492:
0493: try {
0494: numStr = (String) cmbMaxFractional.getSelectedItem();
0495: if (numStr != null && numStr.trim().length() != 0)
0496: maxFractional = Integer.parseInt(numStr);
0497: else
0498: maxFractional = 3;
0499: } catch (NumberFormatException ne) {
0500: valid = false;
0501: msg.append(NbBundle.getMessage(
0502: NumberConverterCustomizerPanel.class,
0503: "badMaxFractionalDigits"));
0504: }
0505:
0506: try {
0507: numStr = (String) cmbMinFractional.getSelectedItem();
0508: if (numStr != null && numStr.trim().length() != 0)
0509: minFractional = Integer.parseInt(numStr);
0510: else
0511: minFractional = 0;
0512: } catch (NumberFormatException ne) {
0513: valid = false;
0514: msg.append(NbBundle.getMessage(
0515: NumberConverterCustomizerPanel.class,
0516: "badMinFractionalDigits"));
0517: }
0518:
0519: // TODO it is here is because insync take 0 as I want defaults
0520: if (maxInteger == 0)
0521: maxInteger = 40;
0522: if (minInteger == 0)
0523: minInteger = 1;
0524: if (maxFractional == 0)
0525: maxFractional = 3;
0526: if (minFractional == 0)
0527: minFractional = 0;
0528:
0529: // Now, make sure the max >= min
0530: if (maxInteger < minInteger) {
0531: valid = false;
0532: msg.append(NbBundle.getMessage(
0533: NumberConverterCustomizerPanel.class,
0534: "badIntegerDigits"));
0535: }
0536:
0537: if (maxFractional < minFractional) {
0538: valid = false;
0539: msg.append(NbBundle.getMessage(
0540: NumberConverterCustomizerPanel.class,
0541: "badFractionalDigits"));
0542: }
0543:
0544: // Currency Symbol
0545: if (cmbType.getSelectedIndex() == 1
0546: && rbSymbol.isSelected()) { // CURRENCY
0547: if (txtEnterSymbol.getText() == null
0548: || txtEnterSymbol.getText().trim().length() == 0) {
0549: valid = false;
0550: msg.append(NbBundle.getMessage(
0551: NumberConverterCustomizerPanel.class,
0552: "emptySymbol"));
0553: }
0554: }
0555: }
0556:
0557: if (rbPattern.isSelected()) {
0558:
0559: // Make sure the pattern is not NULL and valid
0560: String pattern = (String) cmbPattern.getSelectedItem();
0561:
0562: if (pattern == null || pattern.trim().length() == 0) {
0563: valid = false;
0564: msg.append(NbBundle.getMessage(
0565: NumberConverterCustomizerPanel.class,
0566: "emptyPattern"));
0567: }
0568:
0569: try {
0570: ((DecimalFormat) DecimalFormat.getInstance())
0571: .applyPattern(((String) cmbPattern
0572: .getSelectedItem()).trim());
0573: } catch (IllegalArgumentException ie) {
0574: valid = false;
0575: msg.append(NbBundle.getMessage(
0576: NumberConverterCustomizerPanel.class,
0577: "badPattern", pattern));
0578: }
0579: }
0580:
0581: if (!valid) {
0582: // Notify the user
0583: NotifyDescriptor d = new NotifyDescriptor.Message(msg,
0584: NotifyDescriptor.ERROR_MESSAGE);
0585: DialogDisplayer.getDefault().notify(d);
0586: }
0587:
0588: return valid;
0589: }
0590:
0591: // Enable or disable the components in the type part of the panel appropriately based on the
0592: // selected values
0593: private void enableTypePanel() {
0594: boolean typeOn = rbType.isSelected();
0595: cmbType.setEnabled(typeOn);
0596: cmbMinInteger.setEnabled(typeOn);
0597: cmbMaxInteger.setEnabled(typeOn);
0598: cmbMinFractional.setEnabled(typeOn);
0599: cmbMaxFractional.setEnabled(typeOn);
0600: cmbLocale.setEnabled(typeOn);
0601: cbUseGrouping.setEnabled(typeOn);
0602: lblMinFractional.setEnabled(typeOn);
0603: lblMaxFractional.setEnabled(typeOn);
0604: lblMinInteger.setEnabled(typeOn);
0605: lblMaxInteger.setEnabled(typeOn);
0606: lblFractional.setEnabled(typeOn);
0607: lblInteger.setEnabled(typeOn);
0608: lblLocale.setEnabled(typeOn);
0609: lblChooseCurrency.setEnabled(typeOn);
0610: enableCurrencyCombos();
0611: }
0612:
0613: // Enable or disable the components in the pattern part of the panel appropriately based on the
0614: // selected values
0615: private void enablePatternPanel() {
0616: boolean patternOn = rbPattern.isSelected();
0617: cmbPattern.setEnabled(patternOn);
0618: }
0619:
0620: private void enableCurrencyCombos() {
0621:
0622: // The user can edit the symbol and select a currency code only if there is no locale specified
0623: // the specified locale doesn't have currency code and symbol
0624: boolean editableCurrency = false;
0625:
0626: // Update the currency code and symbol based on the selected locale if there is a locale is selected and the
0627: // selected locale has currency code and symbol
0628: Locale selectedLocale = getLocaleBasedOnComboBoxIndex(cmbLocale
0629: .getSelectedIndex());
0630: if (selectedLocale == null) {
0631: editableCurrency = true;
0632: // no locale specified, default to default locale
0633: selectedLocale = Locale.getDefault();
0634: }
0635:
0636: // We'll give our best guess what might be the currency code or symbol
0637: // The user can always modified from the UI
0638: String codeDisplayName = null;
0639: String symbol = null;
0640:
0641: try {
0642: // See whehther we can find the currency code/symbol for the selected locale
0643: Currency cur = Currency.getInstance(selectedLocale);
0644: codeDisplayName = ISO4217CurrencyCode.getDisplayName(cur
0645: .getCurrencyCode());
0646: symbol = cur.getSymbol(selectedLocale);
0647:
0648: } catch (IllegalArgumentException e) {
0649:
0650: // Happens if the locale does not support currency code and symbol
0651: editableCurrency = true;
0652:
0653: // Ok the selected locale or default locale is not good for the currency
0654: // Lets have a best guess... Usually the locale after has the right code/symbol
0655: // If not, the user can always change it in the UI
0656: for (int i = cmbLocale.getSelectedIndex(); i < locales.length; i++) {
0657: try {
0658: Locale locale = getLocaleBasedOnComboBoxIndex(i);
0659: Currency cur = Currency.getInstance(locale);
0660: codeDisplayName = ISO4217CurrencyCode
0661: .getDisplayName(cur.getCurrencyCode());
0662: symbol = cur.getSymbol(locale);
0663:
0664: // Found a good one
0665: break;
0666: } catch (IllegalArgumentException ie) {
0667: // Happens if the locale does not support currency code and symbol
0668: // try the next locale
0669: continue;
0670: } catch (java.lang.NullPointerException ne) {
0671: // Happens if the locale does not have two letter country code
0672: // try the next locale
0673: continue;
0674: }
0675: }
0676: }
0677:
0678: // Disable/enable the currency components properly
0679:
0680: boolean isTypeCurrency = ((cmbType.getSelectedIndex() == 1) && (rbType
0681: .isSelected()));
0682: rbCurrencyCode.setEnabled(isTypeCurrency);
0683: rbSymbol.setEnabled(isTypeCurrency);
0684: lblChooseCurrency.setEnabled(isTypeCurrency);
0685: cmbCurrencyCode.setEnabled(isTypeCurrency);
0686: txtEnterSymbol.setEnabled(isTypeCurrency);
0687:
0688: // If the locale has currency code and symbol, then the user can edit them.
0689: // Otherwise, the user has a choice to select a currency code or enter a symbol
0690:
0691: txtEnterSymbol.setText(symbol);
0692: cmbCurrencyCode.removeAllItems();
0693:
0694: if (!editableCurrency) {
0695: cmbCurrencyCode
0696: .setModel(new javax.swing.DefaultComboBoxModel(
0697: new String[] { codeDisplayName }));
0698: // Make the symbol not editable
0699: txtEnterSymbol.setEditable(false);
0700: } else {
0701: cmbCurrencyCode
0702: .setModel(new javax.swing.DefaultComboBoxModel(
0703: ISO4217CurrencyCode.getDisplayNames()));
0704: // Make the symbol editable
0705: txtEnterSymbol.setEditable(true);
0706: }
0707:
0708: cmbCurrencyCode.setSelectedItem(codeDisplayName);
0709:
0710: if (isTypeCurrency) {
0711: if (rbCurrencyCode.isSelected()) {
0712: txtEnterSymbol.setEnabled(false);
0713: } else {
0714: cmbCurrencyCode.setEnabled(false);
0715: }
0716: }
0717: }
0718:
0719: private void cmbExampleFocusLost(java.awt.event.FocusEvent evt) {
0720: // TODO add your handling code here:
0721:
0722: btnTest.setDefaultCapable(false);
0723: }
0724:
0725: // The sample result will be updated based on the selected type or pattern
0726: private void upateSampleResult() {
0727:
0728: // Valid the user inputs first
0729: if (!validateUserInput())
0730: return;
0731:
0732: // Now wWe'll format the number based on the rules used by NumberConverter.getAsString().
0733: // Here is what the NumberConverter javadoc says:
0734: // The getAsString() method expects a value of type java.lang.Number (or a subclass), and creates a
0735: // formatted String according to the following algorithm:
0736: //
0737: // o If the specified value is null, return a zero-length String.
0738: // o If the specified value is a String, return it unmodified.
0739: // o If the locale property is not null, use that Locale for managing formatting. Otherwise, use the Locale from the FacesContext.
0740: // o If a pattern has been specified, its syntax must conform the rules specified by java.text.DecimalFormat.
0741: // Such a pattern will be used to format, and the type property (along with related formatting options described
0742: // in the next paragraph) will be ignored.
0743: // o If a pattern has not been specified, formatting will be based on the type property, which formats the value
0744: // as a currency, a number, or a percent. The format pattern for currencies, numbers, and percentages is determined
0745: // by calling the percentages is determined by calling the getCurrencyInstance(), getNumberInstance(), or getPercentInstance()
0746: // method of the java.text.NumberFormat class, passing in the selected Locale. In addition, the following properties will be
0747: // applied to the format pattern, if specified:
0748: // - If the groupingUsed property is true, the setGroupingUsed(true) method on the corresponding NumberFormat instance will be called.
0749: // - The minimum and maximum number of digits in the integer and fractional portions of the result will be configured based
0750: // on any values set for the maxFractionDigits, maxIntegerDigits, minFractionDigits, and minIntegerDigits properties.
0751: // - If the type is set to currency, it is also possible to configure the currency symbol to be used, using either the
0752: // currencyCode or currencySymbol properties. If both are set, the value for currencyCode takes precedence on a
0753: // JDK 1.4 (or later) JVM; otherwise, the value for currencySymbol takes precedence.
0754:
0755: double sampleNumber = 0;
0756:
0757: try {
0758: sampleNumber = Double.parseDouble((String) cmbExample
0759: .getSelectedItem());
0760: } catch (NumberFormatException ne) {
0761:
0762: txtResults.setText(NbBundle.getMessage(
0763: NumberConverterCustomizerPanel.class, "notANumber",
0764: (String) cmbExample.getSelectedItem()));
0765: return;
0766: }
0767:
0768: if (rbType.isSelected()) {
0769:
0770: Locale selectedLocale = getLocaleBasedOnComboBoxIndex(cmbLocale
0771: .getSelectedIndex());
0772: if (selectedLocale == null)
0773: selectedLocale = Locale.getDefault();
0774:
0775: // Format based on the type of the converter
0776:
0777: NumberFormat numberFormat;
0778: if (cmbType.getSelectedIndex() == 0) { // number
0779: numberFormat = NumberFormat
0780: .getNumberInstance(selectedLocale);
0781: } else if (cmbType.getSelectedIndex() == 1) { // currency
0782: numberFormat = NumberFormat
0783: .getCurrencyInstance(selectedLocale);
0784:
0785: Currency currency = null;
0786: if (rbCurrencyCode.isSelected()) {
0787: String currencyCode = null;
0788:
0789: // If there is only one item in the combo box, then we can use the
0790: // selected locale the figure out the currency code
0791: if (cmbCurrencyCode.getModel().getSize() == 1) {
0792: currencyCode = Currency.getInstance(
0793: selectedLocale).getCurrencyCode();
0794: } else {
0795: //
0796: int index = cmbCurrencyCode.getSelectedIndex();
0797: currencyCode = ISO4217CurrencyCode
0798: .getCode(index);
0799: }
0800: currency = Currency.getInstance(currencyCode);
0801: numberFormat.setCurrency(currency);
0802: } else {
0803: DecimalFormat df = (DecimalFormat) numberFormat;
0804: DecimalFormatSymbols dfs = df
0805: .getDecimalFormatSymbols();
0806: dfs.setCurrencySymbol(txtEnterSymbol.getText()
0807: .trim());
0808: df.setDecimalFormatSymbols(dfs);
0809: }
0810:
0811: // What do I do if symbol is selected
0812:
0813: } else { // Must be PERCENT
0814: numberFormat = NumberFormat
0815: .getPercentInstance(selectedLocale);
0816: }
0817:
0818: Integer minIntegerDigits = getInteger((String) cmbMinInteger
0819: .getSelectedItem());
0820: Integer maxIntegerDigits = getInteger((String) cmbMaxInteger
0821: .getSelectedItem());
0822: Integer minFractionalDigits = getInteger((String) cmbMinFractional
0823: .getSelectedItem());
0824: Integer maxFractionalDigits = getInteger((String) cmbMaxFractional
0825: .getSelectedItem());
0826:
0827: // Because of a bug in insyn, 0 min/max integer/fractional digits will be considered as I want defaults for now
0828:
0829: if (minIntegerDigits != null
0830: && minIntegerDigits.intValue() != 0)
0831: numberFormat.setMinimumIntegerDigits(minIntegerDigits
0832: .intValue());
0833:
0834: if (maxIntegerDigits != null
0835: && maxIntegerDigits.intValue() != 0)
0836: numberFormat.setMaximumIntegerDigits(maxIntegerDigits
0837: .intValue());
0838:
0839: if (minFractionalDigits != null
0840: && minFractionalDigits.intValue() != 0)
0841: numberFormat
0842: .setMinimumFractionDigits(minFractionalDigits
0843: .intValue());
0844:
0845: if (maxFractionalDigits != null
0846: && maxFractionalDigits.intValue() != 0)
0847: numberFormat
0848: .setMaximumFractionDigits(maxFractionalDigits
0849: .intValue());
0850:
0851: numberFormat.setGroupingUsed(cbUseGrouping.isSelected());
0852: numberFormat
0853: .setParseIntegerOnly(cbIntegerOnly.isSelected());
0854:
0855: txtResults.setText(numberFormat.format(sampleNumber));
0856:
0857: } else {
0858: // Pattern should be used to format the number
0859: DecimalFormat decimalFormat = (DecimalFormat) DecimalFormat
0860: .getInstance();
0861: decimalFormat.applyPattern(((String) cmbPattern
0862: .getSelectedItem()).trim());
0863: decimalFormat.setParseIntegerOnly(cbIntegerOnly
0864: .isSelected());
0865:
0866: txtResults.setText(decimalFormat.format(sampleNumber));
0867: }
0868: }
0869:
0870: /** This method is called from within the constructor to
0871: * initialize the form.
0872: * WARNING: Do NOT modify this code. The content of this method is
0873: * always regenerated by the Form Editor.
0874: */
0875: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
0876: private void initComponents() {
0877: java.awt.GridBagConstraints gridBagConstraints;
0878:
0879: typePatternGroup = new javax.swing.ButtonGroup();
0880: currencyGroup = new javax.swing.ButtonGroup();
0881: pnlTypePattern = new javax.swing.JPanel();
0882: cmbType = new javax.swing.JComboBox();
0883: cmbPattern = new javax.swing.JComboBox();
0884: rbType = new javax.swing.JRadioButton();
0885: rbPattern = new javax.swing.JRadioButton();
0886: pnlType = new javax.swing.JPanel();
0887: pnlFractional = new javax.swing.JPanel();
0888: lblMinFractional = new javax.swing.JLabel();
0889: lblMaxFractional = new javax.swing.JLabel();
0890: cmbMinFractional = new javax.swing.JComboBox();
0891: cmbMaxFractional = new javax.swing.JComboBox();
0892: pnlInteger = new javax.swing.JPanel();
0893: lblMinInteger = new javax.swing.JLabel();
0894: lblMaxInteger = new javax.swing.JLabel();
0895: cmbMinInteger = new javax.swing.JComboBox();
0896: cmbMaxInteger = new javax.swing.JComboBox();
0897: lblFractional = new javax.swing.JLabel();
0898: lblInteger = new javax.swing.JLabel();
0899: cbUseGrouping = new javax.swing.JCheckBox();
0900: pnlLocale = new javax.swing.JPanel();
0901: rbCurrencyCode = new javax.swing.JRadioButton();
0902: cmbLocale = new javax.swing.JComboBox();
0903: lblLocale = new javax.swing.JLabel();
0904: lblChooseCurrency = new javax.swing.JLabel();
0905: rbSymbol = new javax.swing.JRadioButton();
0906: txtEnterSymbol = new javax.swing.JTextField();
0907: cmbCurrencyCode = new javax.swing.JComboBox();
0908: cbIntegerOnly = new javax.swing.JCheckBox();
0909: pnlExample = new javax.swing.JPanel();
0910: jSeparator1 = new javax.swing.JSeparator();
0911: lblExample = new javax.swing.JLabel();
0912: txtResults = new javax.swing.JTextField();
0913: lblResults = new javax.swing.JLabel();
0914: cmbExample = new javax.swing.JComboBox();
0915: btnTest = new javax.swing.JButton();
0916: txtExampleInstructions = new javax.swing.JTextPane();
0917:
0918: addFocusListener(new java.awt.event.FocusAdapter() {
0919: public void focusGained(java.awt.event.FocusEvent evt) {
0920: formFocusGained(evt);
0921: }
0922: });
0923: setLayout(new java.awt.GridBagLayout());
0924:
0925: pnlTypePattern.setLayout(new java.awt.GridBagLayout());
0926:
0927: cmbType.setMinimumSize(new java.awt.Dimension(100, 19));
0928: cmbType.addActionListener(new java.awt.event.ActionListener() {
0929: public void actionPerformed(java.awt.event.ActionEvent evt) {
0930: cmbTypeActionPerformed(evt);
0931: }
0932: });
0933: gridBagConstraints = new java.awt.GridBagConstraints();
0934: gridBagConstraints.gridx = 1;
0935: gridBagConstraints.gridy = 0;
0936: gridBagConstraints.gridwidth = 2;
0937: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0938: gridBagConstraints.weightx = 1.0;
0939: pnlTypePattern.add(cmbType, gridBagConstraints);
0940: java.util.ResourceBundle bundle = java.util.ResourceBundle
0941: .getBundle("org/netbeans/modules/visualweb/faces/dt/converter/Bundle"); // NOI18N
0942: cmbType.getAccessibleContext().setAccessibleName(
0943: bundle.getString("type")); // NOI18N
0944: cmbType.getAccessibleContext().setAccessibleDescription(
0945: bundle.getString("typeDescription")); // NOI18N
0946:
0947: cmbPattern.setEditable(true);
0948: cmbPattern.setEnabled(false);
0949: cmbPattern
0950: .addActionListener(new java.awt.event.ActionListener() {
0951: public void actionPerformed(
0952: java.awt.event.ActionEvent evt) {
0953: cmbPatternActionPerformed(evt);
0954: }
0955: });
0956: gridBagConstraints = new java.awt.GridBagConstraints();
0957: gridBagConstraints.gridx = 1;
0958: gridBagConstraints.gridy = 2;
0959: gridBagConstraints.gridwidth = 2;
0960: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0961: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0962: gridBagConstraints.weightx = 1.0;
0963: pnlTypePattern.add(cmbPattern, gridBagConstraints);
0964: cmbPattern.getAccessibleContext().setAccessibleName(
0965: bundle.getString("pattern")); // NOI18N
0966: cmbPattern.getAccessibleContext().setAccessibleDescription(
0967: bundle.getString("pattern")); // NOI18N
0968:
0969: typePatternGroup.add(rbType);
0970: rbType.setMnemonic(org.openide.util.NbBundle.getBundle(
0971: NumberConverterCustomizerPanel.class).getString(
0972: "type_mnemonic").charAt(0));
0973: rbType.setSelected(true);
0974: rbType.setText(bundle.getString("type")); // NOI18N
0975: rbType.addActionListener(new java.awt.event.ActionListener() {
0976: public void actionPerformed(java.awt.event.ActionEvent evt) {
0977: rbTypeActionPerformed(evt);
0978: }
0979: });
0980: gridBagConstraints = new java.awt.GridBagConstraints();
0981: gridBagConstraints.gridx = 0;
0982: gridBagConstraints.gridy = 0;
0983: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0984: gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 10);
0985: pnlTypePattern.add(rbType, gridBagConstraints);
0986: rbType.getAccessibleContext().setAccessibleName(
0987: bundle.getString("type")); // NOI18N
0988: rbType.getAccessibleContext().setAccessibleDescription(
0989: bundle.getString("typeDescription")); // NOI18N
0990:
0991: typePatternGroup.add(rbPattern);
0992: rbPattern.setMnemonic(org.openide.util.NbBundle.getBundle(
0993: NumberConverterCustomizerPanel.class).getString(
0994: "pattern_mnemonic").charAt(0));
0995: rbPattern.setText(bundle.getString("pattern")); // NOI18N
0996: rbPattern
0997: .addActionListener(new java.awt.event.ActionListener() {
0998: public void actionPerformed(
0999: java.awt.event.ActionEvent evt) {
1000: rbPatternActionPerformed(evt);
1001: }
1002: });
1003: gridBagConstraints = new java.awt.GridBagConstraints();
1004: gridBagConstraints.gridx = 0;
1005: gridBagConstraints.gridy = 2;
1006: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1007: gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 10);
1008: pnlTypePattern.add(rbPattern, gridBagConstraints);
1009: rbPattern.getAccessibleContext().setAccessibleDescription(
1010: bundle.getString("pattern")); // NOI18N
1011:
1012: pnlType.setLayout(new java.awt.GridBagLayout());
1013:
1014: pnlFractional.setLayout(new java.awt.GridBagLayout());
1015:
1016: lblMinFractional.setDisplayedMnemonic(org.openide.util.NbBundle
1017: .getBundle(NumberConverterCustomizerPanel.class)
1018: .getString("minFractional_mnemonic").charAt(0));
1019: lblMinFractional.setLabelFor(cmbMinFractional);
1020: lblMinFractional.setText(bundle.getString("minFractional")); // NOI18N
1021: gridBagConstraints = new java.awt.GridBagConstraints();
1022: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1023: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 10);
1024: pnlFractional.add(lblMinFractional, gridBagConstraints);
1025: lblMinFractional.getAccessibleContext().setAccessibleName(
1026: bundle.getString("minFractional")); // NOI18N
1027: lblMinFractional.getAccessibleContext()
1028: .setAccessibleDescription(
1029: bundle.getString("minFractional")); // NOI18N
1030:
1031: lblMaxFractional.setDisplayedMnemonic(org.openide.util.NbBundle
1032: .getBundle(NumberConverterCustomizerPanel.class)
1033: .getString("maxFractional_mnemonic").charAt(0));
1034: lblMaxFractional.setLabelFor(cmbMaxFractional);
1035: lblMaxFractional.setText(bundle.getString("maxFractional")); // NOI18N
1036: gridBagConstraints = new java.awt.GridBagConstraints();
1037: gridBagConstraints.gridx = 2;
1038: gridBagConstraints.gridy = 0;
1039: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1040: gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 10);
1041: pnlFractional.add(lblMaxFractional, gridBagConstraints);
1042: lblMaxFractional.getAccessibleContext().setAccessibleName(
1043: bundle.getString("maxFractional")); // NOI18N
1044: lblMaxFractional.getAccessibleContext()
1045: .setAccessibleDescription(
1046: bundle.getString("maxFractional")); // NOI18N
1047:
1048: cmbMinFractional.setEditable(true);
1049: gridBagConstraints = new java.awt.GridBagConstraints();
1050: gridBagConstraints.gridx = 1;
1051: gridBagConstraints.gridy = 0;
1052: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1053: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1054: gridBagConstraints.weightx = 0.3;
1055: pnlFractional.add(cmbMinFractional, gridBagConstraints);
1056:
1057: cmbMaxFractional.setEditable(true);
1058: gridBagConstraints = new java.awt.GridBagConstraints();
1059: gridBagConstraints.gridx = 3;
1060: gridBagConstraints.gridy = 0;
1061: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1062: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1063: gridBagConstraints.weightx = 0.3;
1064: pnlFractional.add(cmbMaxFractional, gridBagConstraints);
1065:
1066: gridBagConstraints = new java.awt.GridBagConstraints();
1067: gridBagConstraints.gridx = 1;
1068: gridBagConstraints.gridy = 1;
1069: gridBagConstraints.gridwidth = 3;
1070: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
1071: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1072: gridBagConstraints.insets = new java.awt.Insets(10, 10, 0, 0);
1073: pnlType.add(pnlFractional, gridBagConstraints);
1074:
1075: pnlInteger.setLayout(new java.awt.GridBagLayout());
1076:
1077: lblMinInteger.setDisplayedMnemonic(org.openide.util.NbBundle
1078: .getBundle(NumberConverterCustomizerPanel.class)
1079: .getString("minInteger_mnemonic").charAt(0));
1080: lblMinInteger.setLabelFor(cmbMinInteger);
1081: lblMinInteger.setText(bundle.getString("minInteger")); // NOI18N
1082: gridBagConstraints = new java.awt.GridBagConstraints();
1083: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1084: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 10);
1085: pnlInteger.add(lblMinInteger, gridBagConstraints);
1086: lblMinInteger.getAccessibleContext().setAccessibleName(
1087: bundle.getString("minInteger")); // NOI18N
1088: lblMinInteger.getAccessibleContext().setAccessibleDescription(
1089: bundle.getString("minInteger")); // NOI18N
1090:
1091: lblMaxInteger.setDisplayedMnemonic(org.openide.util.NbBundle
1092: .getBundle(NumberConverterCustomizerPanel.class)
1093: .getString("maxInteger_mnemonic").charAt(0));
1094: lblMaxInteger.setLabelFor(cmbMaxInteger);
1095: lblMaxInteger.setText(bundle.getString("maxInteger")); // NOI18N
1096: gridBagConstraints = new java.awt.GridBagConstraints();
1097: gridBagConstraints.gridx = 2;
1098: gridBagConstraints.gridy = 0;
1099: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1100: gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 10);
1101: pnlInteger.add(lblMaxInteger, gridBagConstraints);
1102: lblMaxInteger.getAccessibleContext().setAccessibleName(
1103: bundle.getString("maxInteger")); // NOI18N
1104: lblMaxInteger.getAccessibleContext().setAccessibleDescription(
1105: bundle.getString("maxInteger")); // NOI18N
1106:
1107: cmbMinInteger.setEditable(true);
1108: gridBagConstraints = new java.awt.GridBagConstraints();
1109: gridBagConstraints.gridx = 1;
1110: gridBagConstraints.gridy = 0;
1111: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1112: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1113: gridBagConstraints.weightx = 0.3;
1114: pnlInteger.add(cmbMinInteger, gridBagConstraints);
1115:
1116: cmbMaxInteger.setEditable(true);
1117: gridBagConstraints = new java.awt.GridBagConstraints();
1118: gridBagConstraints.gridx = 3;
1119: gridBagConstraints.gridy = 0;
1120: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1121: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1122: gridBagConstraints.weightx = 0.3;
1123: pnlInteger.add(cmbMaxInteger, gridBagConstraints);
1124:
1125: gridBagConstraints = new java.awt.GridBagConstraints();
1126: gridBagConstraints.gridx = 1;
1127: gridBagConstraints.gridy = 0;
1128: gridBagConstraints.gridwidth = 3;
1129: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
1130: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1131: gridBagConstraints.insets = new java.awt.Insets(10, 10, 0, 0);
1132: pnlType.add(pnlInteger, gridBagConstraints);
1133:
1134: lblFractional.setDisplayedMnemonic(org.openide.util.NbBundle
1135: .getBundle(NumberConverterCustomizerPanel.class)
1136: .getString("fractionalDigits_mnemonic").charAt(0));
1137: lblFractional.setLabelFor(cmbMinFractional);
1138: lblFractional.setText(bundle.getString("fracDigits")); // NOI18N
1139: gridBagConstraints = new java.awt.GridBagConstraints();
1140: gridBagConstraints.gridx = 0;
1141: gridBagConstraints.gridy = 1;
1142: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1143: gridBagConstraints.insets = new java.awt.Insets(10, 0, 0, 0);
1144: pnlType.add(lblFractional, gridBagConstraints);
1145: lblFractional.getAccessibleContext().setAccessibleName(
1146: bundle.getString("fractionalDigits")); // NOI18N
1147: lblFractional.getAccessibleContext().setAccessibleDescription(
1148: bundle.getString("fractionalDigits")); // NOI18N
1149:
1150: lblInteger.setDisplayedMnemonic(org.openide.util.NbBundle
1151: .getBundle(NumberConverterCustomizerPanel.class)
1152: .getString("integerDigits_mnemonic").charAt(0));
1153: lblInteger.setLabelFor(cmbMinInteger);
1154: lblInteger.setText(bundle.getString("intDigits")); // NOI18N
1155: gridBagConstraints = new java.awt.GridBagConstraints();
1156: gridBagConstraints.gridx = 0;
1157: gridBagConstraints.gridy = 0;
1158: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1159: gridBagConstraints.insets = new java.awt.Insets(10, 0, 0, 0);
1160: pnlType.add(lblInteger, gridBagConstraints);
1161: lblInteger.getAccessibleContext().setAccessibleName(
1162: bundle.getString("integerDigits")); // NOI18N
1163: lblInteger.getAccessibleContext().setAccessibleDescription(
1164: bundle.getString("integerDigits")); // NOI18N
1165:
1166: cbUseGrouping.setMnemonic(org.openide.util.NbBundle.getBundle(
1167: NumberConverterCustomizerPanel.class).getString(
1168: "groupingUsed_mnemonic").charAt(0));
1169: cbUseGrouping.setSelected(true);
1170: cbUseGrouping.setText(bundle.getString("groupingUsed")); // NOI18N
1171: gridBagConstraints = new java.awt.GridBagConstraints();
1172: gridBagConstraints.gridx = 0;
1173: gridBagConstraints.gridy = 2;
1174: gridBagConstraints.gridwidth = 4;
1175: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1176: gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0);
1177: pnlType.add(cbUseGrouping, gridBagConstraints);
1178: cbUseGrouping.getAccessibleContext().setAccessibleDescription(
1179: bundle.getString("groupingUsed")); // NOI18N
1180:
1181: pnlLocale.setLayout(new java.awt.GridBagLayout());
1182:
1183: currencyGroup.add(rbCurrencyCode);
1184: rbCurrencyCode.setMnemonic(org.openide.util.NbBundle.getBundle(
1185: NumberConverterCustomizerPanel.class).getString(
1186: "currencyCode_mnemonic").charAt(0));
1187: rbCurrencyCode.setSelected(true);
1188: rbCurrencyCode.setText(bundle.getString("currencyCode")); // NOI18N
1189: rbCurrencyCode
1190: .addActionListener(new java.awt.event.ActionListener() {
1191: public void actionPerformed(
1192: java.awt.event.ActionEvent evt) {
1193: rbCurrencyCodeActionPerformed(evt);
1194: }
1195: });
1196: gridBagConstraints = new java.awt.GridBagConstraints();
1197: gridBagConstraints.gridx = 0;
1198: gridBagConstraints.gridy = 3;
1199: gridBagConstraints.gridwidth = 2;
1200: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1201: gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0);
1202: pnlLocale.add(rbCurrencyCode, gridBagConstraints);
1203: rbCurrencyCode.getAccessibleContext().setAccessibleDescription(
1204: bundle.getString("currencyCode")); // NOI18N
1205:
1206: cmbLocale
1207: .addActionListener(new java.awt.event.ActionListener() {
1208: public void actionPerformed(
1209: java.awt.event.ActionEvent evt) {
1210: cmbLocaleActionPerformed(evt);
1211: }
1212: });
1213: gridBagConstraints = new java.awt.GridBagConstraints();
1214: gridBagConstraints.gridx = 1;
1215: gridBagConstraints.gridy = 0;
1216: gridBagConstraints.gridwidth = 3;
1217: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1218: gridBagConstraints.weightx = 0.5;
1219: gridBagConstraints.insets = new java.awt.Insets(6, 10, 0, 0);
1220: pnlLocale.add(cmbLocale, gridBagConstraints);
1221: cmbLocale.getAccessibleContext().setAccessibleName(
1222: bundle.getString("locale")); // NOI18N
1223: cmbLocale.getAccessibleContext().setAccessibleDescription(
1224: bundle.getString("locale")); // NOI18N
1225:
1226: lblLocale.setDisplayedMnemonic(org.openide.util.NbBundle
1227: .getBundle(NumberConverterCustomizerPanel.class)
1228: .getString("locale_mnemonic").charAt(0));
1229: lblLocale.setLabelFor(cmbLocale);
1230: lblLocale.setText(bundle.getString("locale")); // NOI18N
1231: gridBagConstraints = new java.awt.GridBagConstraints();
1232: gridBagConstraints.gridx = 0;
1233: gridBagConstraints.gridy = 0;
1234: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1235: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1236: gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
1237: pnlLocale.add(lblLocale, gridBagConstraints);
1238:
1239: lblChooseCurrency
1240: .setDisplayedMnemonic(org.openide.util.NbBundle
1241: .getBundle(NumberConverterCustomizerPanel.class)
1242: .getString("chooseCurrency_mnemonic").charAt(0));
1243: lblChooseCurrency.setLabelFor(cmbCurrencyCode);
1244: lblChooseCurrency.setText(bundle.getString("chooseCurrency")); // NOI18N
1245: gridBagConstraints = new java.awt.GridBagConstraints();
1246: gridBagConstraints.gridx = 0;
1247: gridBagConstraints.gridy = 1;
1248: gridBagConstraints.gridwidth = 4;
1249: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1250: gridBagConstraints.insets = new java.awt.Insets(10, 0, 0, 0);
1251: pnlLocale.add(lblChooseCurrency, gridBagConstraints);
1252: lblChooseCurrency.getAccessibleContext()
1253: .setAccessibleDescription(
1254: bundle.getString("currencyCode")); // NOI18N
1255:
1256: currencyGroup.add(rbSymbol);
1257: rbSymbol.setMnemonic(org.openide.util.NbBundle.getBundle(
1258: NumberConverterCustomizerPanel.class).getString(
1259: "symbol_mnemonic").charAt(0));
1260: rbSymbol.setText(bundle.getString("symbol")); // NOI18N
1261: rbSymbol.addActionListener(new java.awt.event.ActionListener() {
1262: public void actionPerformed(java.awt.event.ActionEvent evt) {
1263: rbSymbolActionPerformed(evt);
1264: }
1265: });
1266: gridBagConstraints = new java.awt.GridBagConstraints();
1267: gridBagConstraints.gridx = 0;
1268: gridBagConstraints.gridy = 4;
1269: gridBagConstraints.gridwidth = 2;
1270: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1271: pnlLocale.add(rbSymbol, gridBagConstraints);
1272: rbSymbol.getAccessibleContext().setAccessibleDescription(
1273: bundle.getString("symbol")); // NOI18N
1274:
1275: txtEnterSymbol.setColumns(10);
1276: txtEnterSymbol
1277: .setHorizontalAlignment(javax.swing.JTextField.LEFT);
1278: txtEnterSymbol.setMinimumSize(new java.awt.Dimension(35, 20));
1279: txtEnterSymbol
1280: .addActionListener(new java.awt.event.ActionListener() {
1281: public void actionPerformed(
1282: java.awt.event.ActionEvent evt) {
1283: txtEnterSymbolActionPerformed(evt);
1284: }
1285: });
1286: gridBagConstraints = new java.awt.GridBagConstraints();
1287: gridBagConstraints.gridx = 2;
1288: gridBagConstraints.gridy = 4;
1289: gridBagConstraints.gridwidth = 2;
1290: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1291: gridBagConstraints.weightx = 0.5;
1292: gridBagConstraints.insets = new java.awt.Insets(2, 10, 0, 0);
1293: pnlLocale.add(txtEnterSymbol, gridBagConstraints);
1294: txtEnterSymbol.getAccessibleContext().setAccessibleName(
1295: bundle.getString("symbol")); // NOI18N
1296: txtEnterSymbol.getAccessibleContext().setAccessibleDescription(
1297: bundle.getString("symbol")); // NOI18N
1298:
1299: cmbCurrencyCode
1300: .addActionListener(new java.awt.event.ActionListener() {
1301: public void actionPerformed(
1302: java.awt.event.ActionEvent evt) {
1303: cmbCurrencyCodeActionPerformed(evt);
1304: }
1305: });
1306: gridBagConstraints = new java.awt.GridBagConstraints();
1307: gridBagConstraints.gridx = 2;
1308: gridBagConstraints.gridy = 3;
1309: gridBagConstraints.gridwidth = 2;
1310: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1311: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
1312: gridBagConstraints.weightx = 1.0;
1313: gridBagConstraints.insets = new java.awt.Insets(6, 10, 0, 0);
1314: pnlLocale.add(cmbCurrencyCode, gridBagConstraints);
1315: cmbCurrencyCode.getAccessibleContext()
1316: .setAccessibleDescription(
1317: bundle.getString("currencyCode")); // NOI18N
1318:
1319: gridBagConstraints = new java.awt.GridBagConstraints();
1320: gridBagConstraints.gridx = 0;
1321: gridBagConstraints.gridy = 3;
1322: gridBagConstraints.gridwidth = 4;
1323: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1324: gridBagConstraints.weightx = 1.0;
1325: gridBagConstraints.weighty = 1.0;
1326: pnlType.add(pnlLocale, gridBagConstraints);
1327:
1328: gridBagConstraints = new java.awt.GridBagConstraints();
1329: gridBagConstraints.gridx = 0;
1330: gridBagConstraints.gridy = 1;
1331: gridBagConstraints.gridwidth = 3;
1332: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1333: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1334: gridBagConstraints.weighty = 1.0;
1335: gridBagConstraints.insets = new java.awt.Insets(0, 30, 6, 10);
1336: pnlTypePattern.add(pnlType, gridBagConstraints);
1337:
1338: cbIntegerOnly.setMnemonic(org.openide.util.NbBundle.getBundle(
1339: NumberConverterCustomizerPanel.class).getString(
1340: "integerOnly_mnemonic").charAt(0));
1341: cbIntegerOnly.setText(bundle.getString("intOnly")); // NOI18N
1342: gridBagConstraints = new java.awt.GridBagConstraints();
1343: gridBagConstraints.gridx = 0;
1344: gridBagConstraints.gridy = 3;
1345: gridBagConstraints.gridwidth = 3;
1346: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1347: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1348: gridBagConstraints.insets = new java.awt.Insets(10, 10, 0, 0);
1349: pnlTypePattern.add(cbIntegerOnly, gridBagConstraints);
1350: cbIntegerOnly.getAccessibleContext().setAccessibleDescription(
1351: bundle.getString("intOnly")); // NOI18N
1352:
1353: gridBagConstraints = new java.awt.GridBagConstraints();
1354: gridBagConstraints.gridx = 0;
1355: gridBagConstraints.gridy = 0;
1356: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1357: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
1358: gridBagConstraints.weightx = 1.0;
1359: gridBagConstraints.weighty = 1.0;
1360: gridBagConstraints.insets = new java.awt.Insets(10, 0, 0, 10);
1361: add(pnlTypePattern, gridBagConstraints);
1362:
1363: pnlExample.setLayout(new java.awt.GridBagLayout());
1364: gridBagConstraints = new java.awt.GridBagConstraints();
1365: gridBagConstraints.gridwidth = 3;
1366: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1367: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
1368: gridBagConstraints.weightx = 1.0;
1369: gridBagConstraints.insets = new java.awt.Insets(10, 0, 0, 0);
1370: pnlExample.add(jSeparator1, gridBagConstraints);
1371:
1372: lblExample.setDisplayedMnemonic(org.openide.util.NbBundle
1373: .getBundle(NumberConverterCustomizerPanel.class)
1374: .getString("example_mnemonic").charAt(0));
1375: lblExample.setLabelFor(cmbExample);
1376: lblExample.setText(bundle.getString("example")); // NOI18N
1377: gridBagConstraints = new java.awt.GridBagConstraints();
1378: gridBagConstraints.gridx = 0;
1379: gridBagConstraints.gridy = 2;
1380: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1381: gridBagConstraints.insets = new java.awt.Insets(10, 10, 0, 0);
1382: pnlExample.add(lblExample, gridBagConstraints);
1383: lblExample.getAccessibleContext().setAccessibleDescription(
1384: bundle.getString("example")); // NOI18N
1385:
1386: txtResults.setEditable(false);
1387: txtResults.setText("1234.56");
1388: gridBagConstraints = new java.awt.GridBagConstraints();
1389: gridBagConstraints.gridx = 1;
1390: gridBagConstraints.gridy = 4;
1391: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1392: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1393: gridBagConstraints.insets = new java.awt.Insets(10, 10, 0, 10);
1394: pnlExample.add(txtResults, gridBagConstraints);
1395: txtResults.getAccessibleContext().setAccessibleName(
1396: bundle.getString("results")); // NOI18N
1397: txtResults.getAccessibleContext().setAccessibleDescription(
1398: bundle.getString("results")); // NOI18N
1399:
1400: lblResults.setDisplayedMnemonic(org.openide.util.NbBundle
1401: .getBundle(NumberConverterCustomizerPanel.class)
1402: .getString("result_mnemonic").charAt(0));
1403: lblResults.setLabelFor(txtResults);
1404: lblResults.setText(bundle.getString("results")); // NOI18N
1405: gridBagConstraints = new java.awt.GridBagConstraints();
1406: gridBagConstraints.gridx = 0;
1407: gridBagConstraints.gridy = 4;
1408: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1409: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
1410: gridBagConstraints.insets = new java.awt.Insets(10, 10, 0, 0);
1411: pnlExample.add(lblResults, gridBagConstraints);
1412: lblResults.getAccessibleContext().setAccessibleDescription(
1413: bundle.getString("results")); // NOI18N
1414:
1415: cmbExample.setEditable(true);
1416: cmbExample
1417: .addActionListener(new java.awt.event.ActionListener() {
1418: public void actionPerformed(
1419: java.awt.event.ActionEvent evt) {
1420: cmbExampleActionPerformed(evt);
1421: }
1422: });
1423: cmbExample.addFocusListener(new java.awt.event.FocusAdapter() {
1424: public void focusGained(java.awt.event.FocusEvent evt) {
1425: cmbExampleFocusGained(evt);
1426: }
1427: });
1428: gridBagConstraints = new java.awt.GridBagConstraints();
1429: gridBagConstraints.gridx = 1;
1430: gridBagConstraints.gridy = 2;
1431: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1432: gridBagConstraints.weightx = 1.0;
1433: gridBagConstraints.insets = new java.awt.Insets(10, 10, 0, 10);
1434: pnlExample.add(cmbExample, gridBagConstraints);
1435: cmbExample.getAccessibleContext().setAccessibleName(
1436: bundle.getString("example")); // NOI18N
1437: cmbExample.getAccessibleContext().setAccessibleDescription(
1438: bundle.getString("example")); // NOI18N
1439:
1440: btnTest.setMnemonic(org.openide.util.NbBundle.getBundle(
1441: NumberConverterCustomizerPanel.class).getString(
1442: "testBtn_mnemonic").charAt(0));
1443: btnTest.setText(bundle.getString("testText")); // NOI18N
1444: btnTest.addActionListener(new java.awt.event.ActionListener() {
1445: public void actionPerformed(java.awt.event.ActionEvent evt) {
1446: btnTestActionPerformed(evt);
1447: }
1448: });
1449: gridBagConstraints = new java.awt.GridBagConstraints();
1450: gridBagConstraints.gridx = 2;
1451: gridBagConstraints.gridy = 2;
1452: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
1453: gridBagConstraints.insets = new java.awt.Insets(10, 0, 0, 0);
1454: pnlExample.add(btnTest, gridBagConstraints);
1455: btnTest.getAccessibleContext().setAccessibleDescription(
1456: bundle.getString("testText")); // NOI18N
1457:
1458: txtExampleInstructions.setBackground(getBackground());
1459: txtExampleInstructions.setBorder(null);
1460: txtExampleInstructions.setEditable(false);
1461: txtExampleInstructions.setText(bundle
1462: .getString("exampleInstructionsText")); // NOI18N
1463: gridBagConstraints = new java.awt.GridBagConstraints();
1464: gridBagConstraints.gridx = 0;
1465: gridBagConstraints.gridy = 1;
1466: gridBagConstraints.gridwidth = 3;
1467: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1468: gridBagConstraints.insets = new java.awt.Insets(10, 10, 0, 11);
1469: pnlExample.add(txtExampleInstructions, gridBagConstraints);
1470: txtExampleInstructions.getAccessibleContext()
1471: .setAccessibleName(
1472: bundle.getString("exampleInstructionsText")); // NOI18N
1473: txtExampleInstructions.getAccessibleContext()
1474: .setAccessibleDescription(
1475: bundle.getString("exampleInstructionsText")); // NOI18N
1476:
1477: gridBagConstraints = new java.awt.GridBagConstraints();
1478: gridBagConstraints.gridx = 0;
1479: gridBagConstraints.gridy = 1;
1480: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1481: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
1482: gridBagConstraints.weightx = 1.0;
1483: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 10);
1484: add(pnlExample, gridBagConstraints);
1485:
1486: getAccessibleContext().setAccessibleName("NumberFormat");
1487: getAccessibleContext().setAccessibleDescription(
1488: "Number Format...");
1489: }// </editor-fold>//GEN-END:initComponents
1490:
1491: private void btnTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTestActionPerformed
1492: // Update the result field
1493: upateSampleResult();
1494: }//GEN-LAST:event_btnTestActionPerformed
1495:
1496: private void cmbExampleActionPerformed(
1497: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbExampleActionPerformed
1498: // Update the result field
1499: upateSampleResult();
1500: }//GEN-LAST:event_cmbExampleActionPerformed
1501:
1502: private void cmbPatternActionPerformed(
1503: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbPatternActionPerformed
1504: // TODO add your handling code here:
1505: }//GEN-LAST:event_cmbPatternActionPerformed
1506:
1507: private void txtEnterSymbolActionPerformed(
1508: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtEnterSymbolActionPerformed
1509: // TODO add your handling code here:
1510: }//GEN-LAST:event_txtEnterSymbolActionPerformed
1511:
1512: private void cmbLocaleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbLocaleActionPerformed
1513: // Update the currency symbol and code
1514: enableCurrencyCombos();
1515: }//GEN-LAST:event_cmbLocaleActionPerformed
1516:
1517: private void cmbCurrencyCodeActionPerformed(
1518: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbCurrencyCodeActionPerformed
1519: // TODO add your handling code here:
1520: }//GEN-LAST:event_cmbCurrencyCodeActionPerformed
1521:
1522: private void rbCurrencyCodeActionPerformed(
1523: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbCurrencyCodeActionPerformed
1524: enableCurrencyCombos();
1525: }//GEN-LAST:event_rbCurrencyCodeActionPerformed
1526:
1527: private void rbSymbolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbSymbolActionPerformed
1528: enableCurrencyCombos();
1529: }//GEN-LAST:event_rbSymbolActionPerformed
1530:
1531: private void cmbTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbTypeActionPerformed
1532: enableCurrencyCombos();
1533: }//GEN-LAST:event_cmbTypeActionPerformed
1534:
1535: private void rbPatternActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbPatternActionPerformed
1536: if (rbPattern.isSelected())
1537: rbType.setSelected(false);
1538: else
1539: rbType.setSelected(true);
1540:
1541: // Enable/disable the components appropriately
1542: enablePatternPanel();
1543: enableTypePanel();
1544: }//GEN-LAST:event_rbPatternActionPerformed
1545:
1546: private void rbTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbTypeActionPerformed
1547: if (rbType.isSelected())
1548: rbPattern.setSelected(false);
1549: else
1550: rbPattern.setSelected(true);
1551:
1552: // Enable/disable the components appropriately
1553: enablePatternPanel();
1554: enableTypePanel();
1555: }//GEN-LAST:event_rbTypeActionPerformed
1556:
1557: private void cmbExampleFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_cmbExampleFocusGained
1558:
1559: //btnOK.setDefaultCapable(false);
1560: btnTest.setDefaultCapable(true);
1561: getRootPane().setDefaultButton(btnTest);
1562: }//GEN-LAST:event_cmbExampleFocusGained
1563:
1564: private void formFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_formFocusGained
1565: // TODO add your handling code here:
1566: }//GEN-LAST:event_formFocusGained
1567:
1568: // Variables declaration - do not modify//GEN-BEGIN:variables
1569: private javax.swing.JButton btnTest;
1570: private javax.swing.JCheckBox cbIntegerOnly;
1571: private javax.swing.JCheckBox cbUseGrouping;
1572: private javax.swing.JComboBox cmbCurrencyCode;
1573: private javax.swing.JComboBox cmbExample;
1574: private javax.swing.JComboBox cmbLocale;
1575: private javax.swing.JComboBox cmbMaxFractional;
1576: private javax.swing.JComboBox cmbMaxInteger;
1577: private javax.swing.JComboBox cmbMinFractional;
1578: private javax.swing.JComboBox cmbMinInteger;
1579: private javax.swing.JComboBox cmbPattern;
1580: private javax.swing.JComboBox cmbType;
1581: private javax.swing.ButtonGroup currencyGroup;
1582: private javax.swing.JSeparator jSeparator1;
1583: private javax.swing.JLabel lblChooseCurrency;
1584: private javax.swing.JLabel lblExample;
1585: private javax.swing.JLabel lblFractional;
1586: private javax.swing.JLabel lblInteger;
1587: private javax.swing.JLabel lblLocale;
1588: private javax.swing.JLabel lblMaxFractional;
1589: private javax.swing.JLabel lblMaxInteger;
1590: private javax.swing.JLabel lblMinFractional;
1591: private javax.swing.JLabel lblMinInteger;
1592: private javax.swing.JLabel lblResults;
1593: private javax.swing.JPanel pnlExample;
1594: private javax.swing.JPanel pnlFractional;
1595: private javax.swing.JPanel pnlInteger;
1596: private javax.swing.JPanel pnlLocale;
1597: private javax.swing.JPanel pnlType;
1598: private javax.swing.JPanel pnlTypePattern;
1599: private javax.swing.JRadioButton rbCurrencyCode;
1600: private javax.swing.JRadioButton rbPattern;
1601: private javax.swing.JRadioButton rbSymbol;
1602: private javax.swing.JRadioButton rbType;
1603: private javax.swing.JTextField txtEnterSymbol;
1604: private javax.swing.JTextPane txtExampleInstructions;
1605: private javax.swing.JTextField txtResults;
1606: private javax.swing.ButtonGroup typePatternGroup;
1607: // End of variables declaration//GEN-END:variables
1608:
1609: }
|