3261N/A * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * <code>NumberFormatter</code> subclasses <code>InternationalFormatter</code> 0N/A * adding special behavior for numbers. Among the specializations are 0N/A * (these are only used if the <code>NumberFormatter</code> does not display 0N/A * invalid nubers, eg <code>setAllowsInvalid(false)</code>): 0N/A * <li>Pressing +/- (- is determined from the 0N/A * <code>DecimalFormatSymbols</code> associated with the 0N/A * <code>DecimalFormat</code>) in any field but the exponent 0N/A * field will attempt to change the sign of the number to 0N/A * <li>Pressing +/- (- is determined from the 0N/A * <code>DecimalFormatSymbols</code> associated with the 0N/A * <code>DecimalFormat</code>) in the exponent field will 0N/A * If you are displaying scientific numbers, you may wish to turn on 0N/A * overwrite mode, <code>setOverwriteMode(true)</code>. For example: 0N/A * DecimalFormat decimalFormat = new DecimalFormat("0.000E0"); 0N/A * NumberFormatter textFormatter = new NumberFormatter(decimalFormat); 0N/A * textFormatter.setOverwriteMode(true); 0N/A * textFormatter.setAllowsInvalid(false); 0N/A * If you are going to allow the user to enter decimal 0N/A * values, you should either force the DecimalFormat to contain at least 0N/A * one decimal (<code>#.0###</code>), or allow the value to be invalid 0N/A * <code>setAllowsInvalid(true)</code>. Otherwise users may not be able to 0N/A * input decimal values. 0N/A * <code>NumberFormatter</code> provides slightly different behavior to 0N/A * <code>stringToValue</code> than that of its superclass. If you have 0N/A * specified a Class for values, {@link #setValueClass}, that is one of 0N/A * of <code>Integer</code>, <code>Long</code>, <code>Float</code>, 0N/A * <code>Double</code>, <code>Byte</code> or <code>Short</code> and 0N/A * the Format's <code>parseObject</code> returns an instance of 0N/A * <code>Number</code>, the corresponding instance of the value class 0N/A * will be created using the constructor appropriate for the primitive 0N/A * type the value class represents. For example: 0N/A * <code>setValueClass(Integer.class)</code> will cause the resulting 0N/A * value to be created via 0N/A * <code>new Integer(((Number)formatter.parseObject(string)).intValue())</code>. 0N/A * This is typically useful if you 0N/A * wish to set a min/max value as the various <code>Number</code> 0N/A * implementations are generally not comparable to each other. This is also 0N/A * useful if for some reason you need a specific <code>Number</code> 0N/A * implementation for your values. 0N/A * <strong>Warning:</strong> 0N/A * Serialized objects of this class will not be compatible with 0N/A * future Swing releases. The current serialization support is 0N/A * appropriate for short term storage or RMI between applications running 0N/A * the same version of Swing. As of 1.4, support for long term storage 0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup> 0N/A * has been added to the <code>java.beans</code> package. 0N/A /** The special characters from the Format instance. */ 0N/A * Creates a <code>NumberFormatter</code> with the a default 0N/A * <code>NumberFormat</code> instance obtained from 0N/A * <code>NumberFormat.getNumberInstance()</code>. 0N/A * Creates a NumberFormatter with the specified Format instance. 0N/A * @param format Format used to dictate legal values 0N/A * Sets the format that dictates the legal values that can be edited 0N/A * If you have used the nullary constructor the value of this property 0N/A * will be determined for the current locale by way of the 0N/A * <code>NumberFormat.getNumberInstance()</code> method. 0N/A * @param format NumberFormat instance used to dictate legal values 0N/A * Invokes <code>parseObject</code> on <code>f</code>, returning 0N/A * Converts the passed in value to the passed in class. This only 0N/A * works if <code>valueClass</code> is one of <code>Integer</code>, 0N/A * <code>Long</code>, <code>Float</code>, <code>Double</code>, 0N/A * <code>Byte</code> or <code>Short</code> and <code>value</code> 0N/A * is an instanceof <code>Number</code>. 0N/A * Returns the character that is used to toggle to positive values. 0N/A * Returns the character that is used to toggle to negative values. 0N/A * Returns the character that is used to toggle to negative values. 0N/A * Returns the DecimalFormatSymbols from the Format instance. 0N/A * Subclassed to return false if <code>text</code> contains in an invalid 0N/A * character to insert, that is, it is not a digit 0N/A * (<code>Character.isDigit()</code>) and 0N/A * not one of the characters defined by the DecimalFormatSymbols. 0N/A * Subclassed to treat the decimal separator, grouping separator, 0N/A * exponent symbol, percent, permille, currency and sign as literals. 0N/A * Subclassed to make the decimal separator navigatable, as well 0N/A * as making the character between the integer field and the next 0N/A * field navigatable. 0N/A // Don't skip the decimal, it causes wierd behavior 0N/A * Returns the first <code>NumberFormat.Field</code> starting 0N/A * <code>index</code> incrementing by <code>direction</code>. 0N/A * Will change the sign of the integer or exponent field if 0N/A * <code>aChar</code> is the positive or minus sign. Returns 0N/A * true if a sign change was attempted. 0N/A * Invoked to toggle the sign. For this to work the value class 0N/A * must have a single arg constructor that takes a String. 0N/A // toString isn't localized, so that using +/- should work 0N/A * Invoked to toggle the sign of the exponent (for scientific