List of usage examples for java.text NumberFormat getIntegerInstance
public static final NumberFormat getIntegerInstance()
From source file:Main.java
public static void main(String[] args) throws Exception { NumberFormat numberFormat = NumberFormat.getIntegerInstance(); System.out.println(numberFormat.getMaximumIntegerDigits()); }
From source file:Main.java
public static void main(String[] args) throws Exception { NumberFormat numberFormat = NumberFormat.getIntegerInstance(); System.out.println(numberFormat.getMaximumFractionDigits()); }
From source file:Main.java
public static void main(String[] args) throws Exception { NumberFormat numberFormat = NumberFormat.getIntegerInstance(); System.out.println(numberFormat.getMinimumIntegerDigits()); }
From source file:Main.java
public static void main(String[] args) throws Exception { NumberFormat numberFormat = NumberFormat.getIntegerInstance(); System.out.println(numberFormat.getMinimumFractionDigits()); }
From source file:Main.java
public static void main(String[] argv) { JFormattedTextField tft1 = new JFormattedTextField(NumberFormat.getIntegerInstance()); tft1.setValue(new Integer(123)); Integer intValue = (Integer) tft1.getValue(); }
From source file:Main.java
/** * Custom creation method for {@link JFormattedTextField}. *//*from www. j a v a2 s . c o m*/ public static JFormattedTextField createIntegerTextField(final int min, final int max, final int now, final int columnNumber) { final NumberFormatter formatter = new NumberFormatter(NumberFormat.getIntegerInstance()); formatter.setMinimum(min); formatter.setMaximum(max); final JFormattedTextField TF = new JFormattedTextField(formatter); TF.setValue(now); TF.setColumns(columnNumber); return TF; }
From source file:Main.java
public Main() { JPanel panel = new JPanel(); JLabel label = new JLabel("Number :"); JFormattedTextField tf = new JFormattedTextField(NumberFormat.getIntegerInstance()); tf.setColumns(10);//from ww w . ja va 2 s . com panel.add(label); panel.add(tf); JButton button = new JButton("Click Me"); panel.add(button); getContentPane().add(panel, BorderLayout.SOUTH); pack(); }
From source file:jenkins.plugins.livingdoc.chart.NumberLabelGenerator.java
NumberLabelGenerator() {
super("", NumberFormat.getIntegerInstance());
}
From source file:org.renjin.base.StrSignIf.java
private static NumberFormat buildFormat(int digits, String format, String flag) { if (format.equals("d")) { return NumberFormat.getIntegerInstance(); } else {/*from w w w. ja v a 2s.co m*/ DecimalFormat formatter; if (format.equals("e")) { formatter = new DecimalFormat("0.00e0"); } else if (format.equals("E")) { formatter = new DecimalFormat("0.00E0"); } else { formatter = new DecimalFormat(); } if (digits < 0) { digits = 6; } formatter.setMaximumFractionDigits(digits); formatter.setMinimumFractionDigits(digits); return formatter; } }
From source file:FormatTest.java
public FormatTestFrame() { setTitle("FormatTest"); setSize(WIDTH, HEIGHT);//w ww . j a va2 s. co m JPanel buttonPanel = new JPanel(); okButton = new JButton("Ok"); buttonPanel.add(okButton); add(buttonPanel, BorderLayout.SOUTH); mainPanel = new JPanel(); mainPanel.setLayout(new GridLayout(0, 3)); add(mainPanel, BorderLayout.CENTER); JFormattedTextField intField = new JFormattedTextField(NumberFormat.getIntegerInstance()); intField.setValue(new Integer(100)); addRow("Number:", intField); JFormattedTextField intField2 = new JFormattedTextField(NumberFormat.getIntegerInstance()); intField2.setValue(new Integer(100)); intField2.setFocusLostBehavior(JFormattedTextField.COMMIT); addRow("Number (Commit behavior):", intField2); JFormattedTextField intField3 = new JFormattedTextField( new InternationalFormatter(NumberFormat.getIntegerInstance()) { protected DocumentFilter getDocumentFilter() { return filter; } private DocumentFilter filter = new IntFilter(); }); intField3.setValue(new Integer(100)); addRow("Filtered Number", intField3); JFormattedTextField intField4 = new JFormattedTextField(NumberFormat.getIntegerInstance()); intField4.setValue(new Integer(100)); intField4.setInputVerifier(new FormattedTextFieldVerifier()); addRow("Verified Number:", intField4); JFormattedTextField currencyField = new JFormattedTextField(NumberFormat.getCurrencyInstance()); currencyField.setValue(new Double(10)); addRow("Currency:", currencyField); JFormattedTextField dateField = new JFormattedTextField(DateFormat.getDateInstance()); dateField.setValue(new Date()); addRow("Date (default):", dateField); DateFormat format = DateFormat.getDateInstance(DateFormat.SHORT); format.setLenient(false); JFormattedTextField dateField2 = new JFormattedTextField(format); dateField2.setValue(new Date()); addRow("Date (short, not lenient):", dateField2); try { DefaultFormatter formatter = new DefaultFormatter(); formatter.setOverwriteMode(false); JFormattedTextField urlField = new JFormattedTextField(formatter); urlField.setValue(new URL("http://java.sun.com")); addRow("URL:", urlField); } catch (MalformedURLException e) { e.printStackTrace(); } try { MaskFormatter formatter = new MaskFormatter("###-##-####"); formatter.setPlaceholderCharacter('0'); JFormattedTextField ssnField = new JFormattedTextField(formatter); ssnField.setValue("078-05-1120"); addRow("SSN Mask:", ssnField); } catch (ParseException exception) { exception.printStackTrace(); } JFormattedTextField ipField = new JFormattedTextField(new IPAddressFormatter()); ipField.setValue(new byte[] { (byte) 130, 65, 86, 66 }); addRow("IP Address:", ipField); }