本文整理了Java中javax.swing.text.NumberFormatter.setValueClass()
方法的一些代码示例,展示了NumberFormatter.setValueClass()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NumberFormatter.setValueClass()
方法的具体详情如下:
包路径:javax.swing.text.NumberFormatter
类名称:NumberFormatter
方法名:setValueClass
暂无
代码示例来源:origin: ballerina-platform/ballerina-lang
public TimeoutGUI() {
rows = Timeout.getTimeoutsJava().entrySet().stream().map(e -> {
NumberFormat format = NumberFormat.getInstance();
NumberFormatter formatter = new NumberFormatter(format);
format.setGroupingUsed(false);
formatter.setValueClass(Integer.class);
formatter.setMinimum(0);
formatter.setAllowsInvalid(true);
formatter.setMaximum(Integer.MAX_VALUE);
final JFormattedTextField field = new JFormattedTextField(formatter);
field.setToolTipText(FIELD_TOOLTIP);
field.setText(e.getValue().toString());
return new AbstractMap.SimpleEntry<>(e.getKey(), field);
}).collect(Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue));
rootPanel = createRootPanel();
}
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) {
NumberFormat format = NumberFormat.getInstance();
NumberFormatter formatter = new NumberFormatter(format);
formatter.setValueClass(Integer.class);
formatter.setMinimum(0);
formatter.setMaximum(Integer.MAX_VALUE);
formatter.setAllowsInvalid(false);
// If you want the value to be committed on each keystroke instead of focus lost
formatter.setCommitsOnValidEdit(true);
JFormattedTextField field = new JFormattedTextField(formatter);
JOptionPane.showMessageDialog(null, field);
// getValue() always returns something valid
System.out.println(field.getValue());
}
代码示例来源:origin: stackoverflow.com
NumberFormatter nf = new NumberFormatter();
nf.setValueClass(Integer.class);
nf.setMinimum(new Integer(0));
nf.setMaximum(new Integer(100));
JFormattedTextField field = new JFormattedTextField(nf);
代码示例来源:origin: stackoverflow.com
NumberFormat longFormat = NumberFormat.getIntegerInstance();
NumberFormatter numberFormatter = new NumberFormatter(longFormat);
numberFormatter.setValueClass(Long.class); //optional, ensures you will always get a long value
numberFormatter.setAllowsInvalid(false); //this is the key!!
numberFormatter.setMinimum(0l); //Optional
JFormattedTextField field = new JFormattedTextField(numberFormatter);
代码示例来源:origin: winterDroid/android-drawable-importer-intellij-plugin
private void createUIComponents() {
NumberFormat format = NumberFormat.getIntegerInstance();
NumberFormatter numberFormatter = new NumberFormatter(format);
numberFormatter.setValueClass(Integer.class);
numberFormatter.setAllowsInvalid(false);
numberFormatter.setMinimum(1);
numberFormatter.setCommitsOnValidEdit(true);
targetHeight = new JFormattedTextField(numberFormatter);
targetWidth = new JFormattedTextField(numberFormatter);
targetRoot = new FileBrowserField(FileBrowserField.RESOURCE_DIR_CHOOSER);
}
}
代码示例来源:origin: org.softsmithy.lib/lib-core
@Override
public void setValueClass(Class valueClass) {
if (! Number.class.isAssignableFrom(valueClass)){
throw new IllegalArgumentException("Number class must be assignable from valueClass");
}
super.setValueClass(valueClass);
}
代码示例来源:origin: org.swinglabs.swingx/swingx-core
/**
* {@inheritDoc} <p>
*
* Overridden to automatically set the minimum/maximum to the boundaries of
* the Number type if it corresponds to a raw type, or null if not.
*/
@Override
public void setValueClass(Class<?> valueClass) {
super.setValueClass(valueClass);
updateMinMax();
}
代码示例来源:origin: net.jradius/jradius-extended
/**
* @return Returns the numberFormatter.
*/
public NumberFormatter getNumberFormatter()
{
if (numberFormatter == null)
{
numberFormatter = new NumberFormatter(NumberFormat.getIntegerInstance());
numberFormatter.setValueClass(Integer.class);
}
return numberFormatter;
}
代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core
/**
* {@inheritDoc} <p>
*
* Overridden to automatically set the minimum/maximum to the boundaries of
* the Number type if it corresponds to a raw type, or null if not.
*/
@Override
public void setValueClass(Class<?> valueClass) {
super.setValueClass(valueClass);
updateMinMax();
}
代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core
/**
* {@inheritDoc} <p>
*
* Overridden to automatically set the minimum/maximum to the boundaries of
* the Number type if it corresponds to a raw type, or null if not.
*/
@Override
public void setValueClass(Class<?> valueClass) {
super.setValueClass(valueClass);
updateMinMax();
}
代码示例来源:origin: org.swinglabs.swingx/swingx-core
/**
* {@inheritDoc} <p>
*
* Overridden to automatically set the minimum/maximum to the boundaries of
* the Number type if it corresponds to a raw type, or null if not.
*/
@Override
public void setValueClass(Class<?> valueClass) {
super.setValueClass(valueClass);
updateMinMax();
}
代码示例来源:origin: org.swinglabs.swingx/swingx-all
/**
* {@inheritDoc} <p>
*
* Overridden to automatically set the minimum/maximum to the boundaries of
* the Number type if it corresponds to a raw type, or null if not.
*/
@Override
public void setValueClass(Class<?> valueClass) {
super.setValueClass(valueClass);
updateMinMax();
}
代码示例来源:origin: com.haulmont.thirdparty/swingx-core
/**
* {@inheritDoc} <p>
*
* Overridden to automatically set the minimum/maximum to the boundaries of
* the Number type if it corresponds to a raw type, or null if not.
*/
@Override
public void setValueClass(Class<?> valueClass) {
super.setValueClass(valueClass);
updateMinMax();
}
代码示例来源:origin: org.swinglabs.swingx/swingx-all
/**
* {@inheritDoc} <p>
*
* Overridden to automatically set the minimum/maximum to the boundaries of
* the Number type if it corresponds to a raw type, or null if not.
*/
@Override
public void setValueClass(Class<?> valueClass) {
super.setValueClass(valueClass);
updateMinMax();
}
代码示例来源:origin: org.cytoscape/filter2-impl
public static NumberFormatter createNumberFormatter() {
NumberFormat format = NumberFormat.getNumberInstance();
NumberFormatter formatter = new NumberFormatter(format);
formatter.setValueClass(Double.class);
formatter.setCommitsOnValidEdit(true);
return formatter;
}
代码示例来源:origin: nroduit/Weasis
public static DefaultFormatterFactory setPreciseDoubleFormat(double min, double max) {
NumberFormatter displayFormatter = new NumberFormatter(new DecimalFormat("#,##0.##")); //$NON-NLS-1$
displayFormatter.setValueClass(Double.class);
NumberFormatter editFormatter = new NumberFormatter(new DecimalFormat("#,##0.0#############")); //$NON-NLS-1$
editFormatter.setValueClass(Double.class);
editFormatter.setMinimum(min);
editFormatter.setMaximum(max);
editFormatter.setAllowsInvalid(true);
return new DefaultFormatterFactory(displayFormatter, displayFormatter, editFormatter);
}
}
代码示例来源:origin: stackoverflow.com
NumberFormat format = NumberFormat.getInstance();
format.setGroupingUsed(false);
NumberFormatter formatter = new NumberFormatter(format);
formatter.setValueClass(Integer.class);
formatter.setMaximum(65535);
formatter.setAllowsInvalid(false);
formatter.setCommitsOnValidEdit(true);
myTextField = new JFormattedTextField(formatter);
代码示例来源:origin: uk.gov.nationalarchives/droid-ui
@Override
public AbstractFormatter getFormatter(JFormattedTextField tf) {
NumberFormatter formatter = new NumberFormatter(new DecimalFormat("#0"));
formatter.setValueClass(Integer.class);
formatter.setAllowsInvalid(true);
formatter.setCommitsOnValidEdit(false);
formatter.setMinimum(0);
return formatter;
};
}
代码示例来源:origin: bcdev/beam
private JFormattedTextField getNumberTextField(double value) {
final NumberFormatter formatter = new NumberFormatter(new DecimalFormat("0.0############"));
formatter.setValueClass(Double.class); // to ensure that double values are returned
final JFormattedTextField numberField = new JFormattedTextField(formatter);
numberField.setValue(value);
final Dimension preferredSize = numberField.getPreferredSize();
preferredSize.width = 70;
numberField.setPreferredSize(preferredSize);
return numberField;
}
代码示例来源:origin: org.cytoscape/filter2-impl
public static NumberFormatter createIntegerFormatter(int minimum, int maximum) {
NumberFormat format = NumberFormat.getIntegerInstance();
NumberFormatter formatter = new NumberFormatter(format);
formatter.setMinimum(minimum);
formatter.setMaximum(maximum);
formatter.setValueClass(Integer.class);
formatter.setCommitsOnValidEdit(true);
return formatter;
}
内容来源于网络,如有侵权,请联系作者删除!