本文整理匯總了Java中javax.swing.text.NumberFormatter.stringToValue方法的典型用法代碼示例。如果您正苦於以下問題:Java NumberFormatter.stringToValue方法的具體用法?Java NumberFormatter.stringToValue怎麽用?Java NumberFormatter.stringToValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.text.NumberFormatter
的用法示例。
在下文中一共展示了NumberFormatter.stringToValue方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testNumberFormatter
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
@Test (expected = ParseException.class)
public void testNumberFormatter() throws ParseException {
NumberFormat format = NumberFormat.getIntegerInstance();
NumberFormatter formatter = new NumberFormatter(format);
formatter.setMaximum(Integer.MAX_VALUE - 1);
formatter.setMinimum(Integer.MIN_VALUE + 1);
formatter.stringToValue(TOO_BIG_INTEGER);
}
示例2: testStrictNumberFormatterMinMax
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
@Test (expected = ParseException.class)
public void testStrictNumberFormatterMinMax() throws ParseException {
NumberFormat format = NumberFormat.getIntegerInstance();
NumberFormatter formatter = new StrictNumberFormatter(format);
formatter.setMaximum(Integer.MAX_VALUE);
formatter.setMinimum(Integer.MIN_VALUE);
formatter.stringToValue(TOO_BIG_INTEGER);
}
示例3: testStrictNumberFormatterAutoRangeInteger
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
@Test (expected = ParseException.class)
public void testStrictNumberFormatterAutoRangeInteger() throws ParseException {
NumberFormat format = NumberFormat.getIntegerInstance();
NumberFormatter formatter = new StrictNumberFormatter(format);
formatter.setValueClass(Integer.class);
formatter.stringToValue(TOO_BIG_INTEGER);
}
示例4: testStrictNumberFormatterAutoRangeLong
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
@Test (expected = ParseException.class)
public void testStrictNumberFormatterAutoRangeLong() throws ParseException {
NumberFormat format = NumberFormat.getIntegerInstance();
NumberFormatter formatter = new StrictNumberFormatter(format);
formatter.setValueClass(Long.class);
String text = new Long(Long.MAX_VALUE).toString() + "9";
formatter.stringToValue(text);
}
示例5: testStrictNumberFormatterAutoRangeFloat
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
@Test (expected = ParseException.class)
public void testStrictNumberFormatterAutoRangeFloat() throws ParseException {
NumberFormat format = NumberFormat.getInstance();
NumberFormatter formatter = new StrictNumberFormatter(format);
formatter.setValueClass(Float.class);
String text = "9" + new Float(Float.MAX_VALUE).toString();
formatter.stringToValue(text);
}
示例6: testStrictNumberFormatterAutoRangeFloatMin
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
@Test (expected = ParseException.class)
public void testStrictNumberFormatterAutoRangeFloatMin() throws ParseException {
NumberFormat format = NumberFormat.getInstance();
NumberFormatter formatter = new StrictNumberFormatter(format);
formatter.setValueClass(Float.class);
String text = "-9" + new Float(Float.MAX_VALUE).toString();
formatter.stringToValue(text);
}
示例7: testStrictNumberFormatterAutoRangeByte
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
@Test (expected = ParseException.class)
public void testStrictNumberFormatterAutoRangeByte() throws ParseException {
NumberFormat format = NumberFormat.getIntegerInstance();
NumberFormatter formatter = new StrictNumberFormatter(format);
formatter.setValueClass(Byte.class);
formatter.stringToValue(TOO_BIG_INTEGER);
}
示例8: testStrictNumberFormatterAutoRangeShort
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
@Test (expected = ParseException.class)
public void testStrictNumberFormatterAutoRangeShort() throws ParseException {
NumberFormat format = NumberFormat.getIntegerInstance();
NumberFormatter formatter = new StrictNumberFormatter(format);
formatter.setValueClass(Short.class);
formatter.stringToValue(TOO_BIG_INTEGER);
}
示例9: testStrictNumberFormatterSmallExceedInteger
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
@Test (expected = ParseException.class)
public void testStrictNumberFormatterSmallExceedInteger() throws ParseException {
NumberFormat format = NumberFormat.getIntegerInstance();
NumberFormatter formatter = new StrictNumberFormatter(format);
formatter.setValueClass(Integer.class);
String text = new Integer(Integer.MAX_VALUE).toString() + "1";
formatter.stringToValue(text);
}
示例10: testNumberFormatterDouble
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
/**
* This is not really an issue: Double values exceeding the bounds are Infinity.
*/
@Test (expected = ParseException.class)
public void testNumberFormatterDouble() throws ParseException {
NumberFormat format = NumberFormat.getInstance();
// no need to do anything special - parsing of doubles fails if out-off range?
NumberFormatter formatter = new NumberFormatter(format);
String text = "9" + new Double(Double.MAX_VALUE).toString();
Number number = (Number) formatter.stringToValue(text);
LOG.info("number: " + number);
}
示例11: testNumberFormatterEmptyStringValue
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
/**
* NumberFormatter parsing can't handle null.
*
* @throws ParseException
*/
@Test
public void testNumberFormatterEmptyStringValue() throws ParseException {
NumberFormat format = NumberFormat.getIntegerInstance();
NumberFormatter formatter = new NumberFormatter(format);
formatter.stringToValue("");
}
示例12: testNumberFormatterNullValue
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
/**
* NumberFormatter parsing can't handle null.
* @throws ParseException
*/
@Test
public void testNumberFormatterNullValue() throws ParseException {
NumberFormat format = NumberFormat.getIntegerInstance();
NumberFormatter formatter = new NumberFormatter(format);
formatter.stringToValue(null);
}
示例13: testNumberFormatterMinMax
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
@Test (expected = ParseException.class)
public void testNumberFormatterMinMax() throws ParseException {
NumberFormat format = NumberFormat.getIntegerInstance();
NumberFormatter formatter = new NumberFormatter(format);
formatter.setMaximum(Integer.MAX_VALUE);
formatter.setMinimum(Integer.MIN_VALUE);
formatter.stringToValue(TOO_BIG_INTEGER);
}