// Support an integer number; if a decimal point is typed, // the decimal point and all following characters are discarded JFormattedTextField tft1 = new JFormattedTextField(NumberFormat.getIntegerInstance()); tft1.setValue(new Integer(123)); // Retrieve the value from the text field Integer intValue = (Integer)tft1.getValue(); // Support a decimal number with one digit following the decimal point; // if more digits after the decimal point is typed, the value is rounded to one decimal place JFormattedTextField tft2 = new JFormattedTextField(new DecimalFormat("#.0")); tft2.setValue(new Float(123.4F)); // Retrieve the value from the text field Float floatValue = (Float)tft2.getValue();