javax.swing.text.NumberFormatter.setMaximum()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(88)

本文整理了Java中javax.swing.text.NumberFormatter.setMaximum()方法的一些代码示例,展示了NumberFormatter.setMaximum()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NumberFormatter.setMaximum()方法的具体详情如下:
包路径:javax.swing.text.NumberFormatter
类名称:NumberFormatter
方法名:setMaximum

NumberFormatter.setMaximum介绍

暂无

代码示例

代码示例来源: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: org.swinglabs.swingx/swingx-core

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void setMaximum(Comparable max) {
  super.setMaximum(max);
  this.maxAsBig = max != null ? new BigDecimal(max.toString()) : null;
}

代码示例来源:origin: com.haulmont.thirdparty/swingx-core

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void setMaximum(Comparable max) {
  super.setMaximum(max);
  this.maxAsBig = max != null ? new BigDecimal(max.toString()) : null;
}

代码示例来源:origin: com.haulmont.thirdparty/swingx-core

@SuppressWarnings("unchecked")
@Override
public void setMaximum(Comparable max) {
  super.setMaximum(max);
  this.maxAsBig = max != null ? new BigDecimal(max.toString()) : null;
}

代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core

@SuppressWarnings("unchecked")
@Override
public void setMaximum(Comparable max) {
  super.setMaximum(max);
  this.maxAsBig = max != null ? new BigDecimal(max.toString()) : null;
}

代码示例来源:origin: org.swinglabs.swingx/swingx-core

@SuppressWarnings("unchecked")
@Override
public void setMaximum(Comparable max) {
  super.setMaximum(max);
  this.maxAsBig = max != null ? new BigDecimal(max.toString()) : null;
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void setMaximum(Comparable max) {
  super.setMaximum(max);
  this.maxAsBig = max != null ? new BigDecimal(max.toString()) : null;
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

@SuppressWarnings("unchecked")
@Override
public void setMaximum(Comparable max) {
  super.setMaximum(max);
  this.maxAsBig = max != null ? new BigDecimal(max.toString()) : null;
}

代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void setMaximum(Comparable max) {
  super.setMaximum(max);
  this.maxAsBig = max != null ? new BigDecimal(max.toString()) : null;
}

代码示例来源:origin: stackoverflow.com

NumberFormatter nf = new NumberFormatter();
nf.setMinimum(new Integer(30));
nf.setMaximum(new Integer(70));
final JFormattedTextField field = new JFormattedTextField(nf);

代码示例来源:origin: stackoverflow.com

NumberFormatter nf = new NumberFormatter();  
nf.setMinimum(new Integer(0));  
nf.setMaximum(new Integer(8));  
JFormattedTextField field = new JFormattedTextField(nf);

代码示例来源:origin: stackoverflow.com

public static void main(String[] args) {
  NumberFormat format = NumberFormat.getInstance();
  format.setGroupingUsed(false);
  NumberFormatter formatter = new NumberFormatter(format);
  formatter.setValueClass(Integer.class);
  formatter.setMinimum(0);
  formatter.setMaximum(Integer.MAX_VALUE);
  JFormattedTextField field = new JFormattedTextField(formatter);
  JOptionPane.showMessageDialog(null, field);
}

代码示例来源: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: stackoverflow.com

NumberFormat format = NumberFormat.getCurrencyInstance(Locale.US);
format.setMaximumFractionDigits(0);

NumberFormatter formatter = new NumberFormatter(format);
formatter.setMinimum(5.0);
formatter.setMaximum(10000000.0);
formatter.setAllowsInvalid(false);
formatter.setOverwriteMode(true);

JFormattedTextField field = new JFormattedTextField(formatter);
field.setValue(5.0);

代码示例来源: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;
}

代码示例来源: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: sing-group/GC4S

private AbstractFormatter configureFormatter() {
  NumberFormat format = NumberFormat.getInstance();
  NumberFormatter formatter = new NumberFormatter(format);
  formatter.setValueClass(Integer.class);
  formatter.setMinimum(0);
  formatter.setMaximum(Integer.MAX_VALUE);
  formatter.setAllowsInvalid(false);
  formatter.setCommitsOnValidEdit(true);
  return formatter;
}

代码示例来源:origin: org.boofcv/boofcv-swing

public static JFormattedTextField createTextField( int current , int min , int max ) {
    NumberFormat format = NumberFormat.getInstance();
    NumberFormatter formatter = new NumberFormatter(format);
    formatter.setValueClass(Integer.class);
    formatter.setMinimum(min);
    formatter.setMaximum(max);
    formatter.setAllowsInvalid(true);
//        formatter.setCommitsOnValidEdit(true);
    JFormattedTextField field = new JFormattedTextField(formatter);
    field.setHorizontalAlignment(JTextField.RIGHT);
    field.setValue(current);
    return field;
  }

相关文章