List of usage examples for com.jgoodies.binding.adapter BasicComponentFactory createIntegerField
public static JFormattedTextField createIntegerField(ValueModel valueModel, NumberFormat numberFormat)
From source file:com.mrfeinberg.proxyprefs.ProxyPrefsEditorBuilder.java
License:Apache License
private void initComponents() { hostField = BasicComponentFactory.createTextField( proxyPrefsPresentationModel.getBufferedModel(ProxyPreferences.PROPERTYNAME_PROXY_HOST)); portField = BasicComponentFactory.createIntegerField( proxyPrefsPresentationModel.getBufferedModel(ProxyPreferences.PROPERTYNAME_PROXY_PORT), new DecimalFormat("0")); useProxyCheckbox = BasicComponentFactory.createCheckBox( proxyPrefsPresentationModel.getBufferedModel(ProxyPreferences.PROPERTYNAME_USE_PROXY), "Use HTTP Proxy"); useProxyCheckbox.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { enableFields();//from w w w. j av a 2 s .c o m } }); enableFields(); }
From source file:org.archiviststoolkit.swing.ATBasicComponentFactory.java
License:Open Source License
public static JFormattedTextField createIntegerField(PresentationModel detailsModel, String fieldName, boolean useGrouping, boolean buffered) { NumberFormat nf = NumberFormat.getIntegerInstance(); nf.setGroupingUsed(useGrouping);//from w w w . j a v a2 s . com JFormattedTextField returnField; if (buffered) { returnField = BasicComponentFactory.createIntegerField(detailsModel.getBufferedModel(fieldName), nf); } else { returnField = BasicComponentFactory.createIntegerField(detailsModel.getModel(fieldName), nf); } returnField.addFocusListener( new ATFormattedTextFocusListener(returnField, "Invalid entry. This field requires an integer.")); return returnField; }
From source file:org.archiviststoolkit.swing.ATBasicComponentFactory.java
License:Open Source License
/** * Method to create a formated textfield which only accepts integers with a certain range * @param detailsModel The details model * @param fieldName The field name to bound to * @param min The minimum value allowed/*from w w w .j ava 2 s . c om*/ * @param max The maximum value allowed * @return */ public static JFormattedTextField createIntegerField(PresentationModel detailsModel, String fieldName, int min, int max) { NumberFormat nf = NumberFormat.getIntegerInstance(); JFormattedTextField returnField; returnField = BasicComponentFactory.createIntegerField(detailsModel.getModel(fieldName), nf); returnField.addFocusListener(new ATFormattedTextFocusListener(returnField, "Invalid entry. This field requires an integer between " + min + " and " + max, min, max)); return returnField; }