List of usage examples for javax.swing.text NumberFormatter NumberFormatter
public NumberFormatter(NumberFormat format)
From source file:org.yccheok.jstock.gui.NewSellTransactionJDialog.java
private JFormattedTextField getCurrencyJFormattedTextField(boolean isNegativeAllowed) { NumberFormat format = NumberFormat.getNumberInstance(); format.setMaximumFractionDigits(4);//from ww w. ja va2 s . co m NumberFormatter formatter = new NumberFormatter(format); if (isNegativeAllowed == false) formatter.setMinimum(0.0); else formatter.setMinimum(null); formatter.setValueClass(Double.class); JFormattedTextField formattedTextField = new JFormattedTextField(formatter); formattedTextField.addMouseListener(getJFormattedTextFieldMouseListener()); return formattedTextField; }
From source file:org.yccheok.jstock.gui.OptionsNetworkJPanel.java
private JFormattedTextField getPortNumberJFormattedTextField() { DecimalFormat df = new DecimalFormat("#####"); NumberFormatter nf = new NumberFormatter(df) { @Override/*from w ww . ja v a 2s . c o m*/ public String valueToString(Object iv) throws ParseException { if ((iv == null) || (((Integer) iv).intValue() == -1)) { return ""; } else { return super.valueToString(iv); } } @Override public Object stringToValue(String text) throws ParseException { if ("".equals(text)) { return null; } return super.stringToValue(text); } }; nf.setMinimum(0); nf.setMaximum(65534); nf.setValueClass(Integer.class); return new JFormattedTextField(nf); }
From source file:org.yccheok.jstock.gui.OptionsSellAdvisorJPanel.java
private JFormattedTextField getPercentageJFormattedTextField() { NumberFormat format = NumberFormat.getNumberInstance(); NumberFormatter formatter = new NumberFormatter(format); formatter.setMinimum(0.0);//from w w w .ja v a 2s .com formatter.setMaximum(null); formatter.setValueClass(Double.class); JFormattedTextField field = new JFormattedTextField(formatter); return field; }
From source file:org.yccheok.jstock.gui.portfolio.AutoDividendJDialog.java
private JFormattedTextField getCurrencyJFormattedTextField() { NumberFormat format = NumberFormat.getNumberInstance(); format.setMaximumFractionDigits(3);//from w w w. j av a 2 s .c o m NumberFormatter formatter = new NumberFormatter(format); formatter.setMinimum(0.0); formatter.setValueClass(Double.class); JFormattedTextField formattedTextField = new JFormattedTextField(formatter); formattedTextField.addMouseListener(getJFormattedTextFieldMouseListener()); return formattedTextField; }
From source file:org.yccheok.jstock.gui.portfolio.SplitJDialog.java
private JFormattedTextField getUnitJFormattedTextField() { NumberFormat format = new DecimalFormat("#,##0.###"); NumberFormatter formatter = new NumberFormatter(format); formatter.setMinimum(1.0);//w w w . j av a 2 s. co m formatter.setValueClass(Double.class); JFormattedTextField field = new JFormattedTextField(formatter); return field; }