本文整理汇总了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);
}