当前位置: 首页>>代码示例>>Java>>正文


Java NumberFormatter.setMinimum方法代码示例

本文整理汇总了Java中javax.swing.text.NumberFormatter.setMinimum方法的典型用法代码示例。如果您正苦于以下问题:Java NumberFormatter.setMinimum方法的具体用法?Java NumberFormatter.setMinimum怎么用?Java NumberFormatter.setMinimum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.text.NumberFormatter的用法示例。


在下文中一共展示了NumberFormatter.setMinimum方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initializeTextFields

import javax.swing.text.NumberFormatter; //导入方法依赖的package包/类
private void initializeTextFields() {

		DecimalFormatSymbols symbols = new DecimalFormatSymbols();
		symbols.setDecimalSeparator('.');

		NumberFormat format = new DecimalFormat("0.00", symbols);
		format.setMaximumFractionDigits(2);

		NumberFormatter formatter = new NumberFormatter(format);
		formatter.setMinimum(0.0);
		formatter.setMaximum(10000000.0);
		formatter.setAllowsInvalid(false);

		this.txtPeso = new JFormattedTextField(formatter);
		this.txtPeso.setValue(0.0);

		GridBagConstraints gbc_textField = new GridBagConstraints();
		gbc_textField.gridwidth = 10;
		gbc_textField.insets = new Insets(0, 0, 5, 0);
		gbc_textField.fill = GridBagConstraints.BOTH;
		gbc_textField.gridx = 2;
		gbc_textField.gridy = 10;
		this.panelSecond.add(this.txtPeso, gbc_textField);
		this.txtPeso.setColumns(10);

	}
 
开发者ID:cjlcarvalho,项目名称:LogisticApp,代码行数:27,代码来源:MenuContratacaoTransporteFrame.java

示例2: WettDialog

import javax.swing.text.NumberFormatter; //导入方法依赖的package包/类
/**
    * Creates a new WettDialog and displays the given array of snails.
    * @param parent The Form opening this dialog
    * @param schneggen The array of snails to display
    * @param wettbueroFactor The factor the Wettbuero uses.
    */
   public WettDialog(Frame parent, ArrayList<Rennschnecke> schneggen, double wettbueroFactor) {
       super(parent, true);
       initComponents();
       NumberFormat format = NumberFormat.getCurrencyInstance();
format.setMinimumFractionDigits(2);
format.setMaximumFractionDigits(2);
       NumberFormatter nf = new NumberFormatter(format);
       nf.setMinimum(0.02);
// The maximum bet value is, well, pretty high.
       nf.setMaximum(Double.MAX_VALUE / wettbueroFactor);
       nf.setAllowsInvalid(false);
       nf.setCommitsOnValidEdit(true);
       nf.setOverwriteMode(false);
       einsatzInput.setFormatterFactory(
               new DefaultFormatterFactory(nf)
       );
       result = null;
       snailList.setModel(new DefaultListModel<>());
       snailList.setListData(schneggen.toArray(new Rennschnecke[schneggen.size()]));
   }
 
开发者ID:Follpvosten,项目名称:schneckenrennen,代码行数:27,代码来源:WettDialog.java

示例3: JNumberField

import javax.swing.text.NumberFormatter; //导入方法依赖的package包/类
public JNumberField(double defaultNumber, double minValue, double maxValue, double increment)
{
    super(new SpinnerNumberModel(defaultNumber, minValue, maxValue, increment));

    final NumberEditor editor = (NumberEditor) this.getEditor();
    editor.getFormat().setMinimumFractionDigits(2);
    editor.getFormat().setMaximumFractionDigits(6);

    final JFormattedTextField spinnerTextEditor = editor.getTextField();
    spinnerTextEditor.setColumns(6);
    spinnerTextEditor.setHorizontalAlignment(JTextField.CENTER);

    final NumberFormatter numberFormatter = new NumberFormatter(editor.getFormat());
    numberFormatter.setValueClass(Double.class);
    numberFormatter.setMinimum(0d);
    numberFormatter.setMaximum(Double.MAX_VALUE);
    numberFormatter.setAllowsInvalid(false);

    spinnerTextEditor.setFormatterFactory(new JFormattedTextField(numberFormatter).getFormatterFactory());
}
 
开发者ID:girtel,项目名称:Net2Plan,代码行数:21,代码来源:JNumberField.java

示例4: getImageSizePanel

import javax.swing.text.NumberFormatter; //导入方法依赖的package包/类
private JPanel getImageSizePanel() {
	JPanel imageSizePanel = new JPanel();
	imageSizePanel.setLayout(new GridLayout(1, 4));
	
    NumberFormat format = NumberFormat.getInstance();
    format.setGroupingUsed(false);
    NumberFormatter formatter = new NumberFormatter(format);
    formatter.setValueClass(Integer.class);
    formatter.setMinimum(0);
    formatter.setMaximum(Integer.MAX_VALUE);
    formatter.setCommitsOnValidEdit(true);
    widthTF = new JFormattedTextField(formatter);
    widthTF.setValue(1200);
    addFocusListener(widthTF);
    heightTF = new JFormattedTextField(formatter);
    heightTF.setValue(1000);
    addFocusListener(heightTF);
    
    imageSizePanel.add(new JLabel(" Width:"));
    imageSizePanel.add(widthTF);
    imageSizePanel.add(new JLabel(" Height:"));
    imageSizePanel.add(heightTF);
    
	return imageSizePanel;
}
 
开发者ID:sing-group,项目名称:la-images,代码行数:26,代码来源:ExportAllAsPngDialog.java

示例5: getImageSizePanel

import javax.swing.text.NumberFormatter; //导入方法依赖的package包/类
private JPanel getImageSizePanel() {
	JPanel imageSizePanel = new JPanel();
	imageSizePanel.setLayout(new GridLayout(1, 4));
	
    NumberFormat format = NumberFormat.getInstance();
    format.setGroupingUsed(false);
    NumberFormatter formatter = new NumberFormatter(format);
    formatter.setValueClass(Integer.class);
    formatter.setMinimum(0);
    formatter.setMaximum(Integer.MAX_VALUE);
    formatter.setCommitsOnValidEdit(true);
    widthTF = new JFormattedTextField(formatter);
    widthTF.setValue(1200);
    widthTF.addFocusListener(FOCUS_LISTENER);
    heightTF = new JFormattedTextField(formatter);
    heightTF.setValue(1000);
    heightTF.addFocusListener(FOCUS_LISTENER);
    
    imageSizePanel.add(new JLabel(" Width:"));
    imageSizePanel.add(widthTF);
    imageSizePanel.add(new JLabel(" Height:"));
    imageSizePanel.add(heightTF);
    
	return imageSizePanel;
}
 
开发者ID:sing-group,项目名称:la-images,代码行数:26,代码来源:ExportAsPngDialog.java

示例6: getIntegerTextField

import javax.swing.text.NumberFormatter; //导入方法依赖的package包/类
public JFormattedTextField getIntegerTextField(Integer min, Integer max, Integer value) {
    NumberFormat format = NumberFormat.getInstance();
    NumberFormatter formatter = new NumberFormatter(format);
    formatter.setValueClass(Integer.class);
    formatter.setMinimum(min);
    formatter.setMaximum(max);
    formatter.setAllowsInvalid(true);
    formatter.setCommitsOnValidEdit(false);

    JFormattedTextField field = new JFormattedTextField(formatter);
    field.setValue(value);
    field.setFont(REGULAR_FONT.deriveFont(scale * 18));
    field.setFocusLostBehavior(JFormattedTextField.PERSIST);
    field.setForeground(AppThemeColor.TEXT_DEFAULT);
    field.setCaretColor(AppThemeColor.TEXT_DEFAULT);
    field.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createLineBorder(AppThemeColor.BORDER, 1),
            BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT, 3)
    ));
    field.setBackground(AppThemeColor.HEADER);
    return field;
}
 
开发者ID:Exslims,项目名称:MercuryTrade,代码行数:23,代码来源:ComponentsFactory.java

示例7: initTickRateField

import javax.swing.text.NumberFormatter; //导入方法依赖的package包/类
/**
 * Erzeugt ein Anzeigefeld fuer den Simulatortakt
 */
@SuppressWarnings("boxing") void initTickRateField() {
	NumberFormatter formatter = new NumberFormatter(NumberFormat.getInstance());
	formatter.setMinimum(StatusBar.MIN_TICK_RATE);
	formatter.setMaximum(StatusBar.MAX_TICK_RATE);
	
	tickRateField = new JFormattedTextField(formatter);
	tickRateField.setValue(INIT_TICK_RATE);
	tickRateField.setColumns(3);
	tickRateField.setHorizontalAlignment(SwingConstants.CENTER);
	tickRateField.setMinimumSize(new Dimension(44, 22));
	tickRateField.setMaximumSize(new Dimension(44, 22));
	tickRateField.setPreferredSize(new Dimension(44, 22));
	
	tickRateField.addPropertyChangeListener(new PropertyChangeListener() {
		@SuppressWarnings("synthetic-access")
		public void propertyChange(PropertyChangeEvent evt) {
			if ("value".equals(evt.getPropertyName())) {
				tickRateSlider.setValue((Integer) tickRateField.getValue());
			}
		}
	});
}
 
开发者ID:tsandmann,项目名称:ct-sim,代码行数:26,代码来源:StatusBar.java

示例8: initFormats

import javax.swing.text.NumberFormatter; //导入方法依赖的package包/类
private void initFormats() {
    nfInteger = NumberFormat.getIntegerInstance();
    NumberFormatter nf = new NumberFormatter(nfInteger);
    nf.setMaximum(Server.MAX_PORT_INDEX);
    nf.setMinimum(0);

    NumberFormat editFormat = NumberFormat.getIntegerInstance();
    editFormat.setGroupingUsed(false);
    NumberFormatter editFormatter = new NumberFormatter(editFormat);
    editFormatter.setMaximum(Server.MAX_PORT_INDEX);
    editFormatter.setMinimum(0);

    integerFormatter = new DefaultFormatterFactory(nf, nf, editFormatter, nf);
    port.setFormatterFactory(integerFormatter);
    port.setValue(28015);
    refreshFrequency.setFormatterFactory(integerFormatter);
    refreshFrequency.setValue(1);
}
 
开发者ID:Ninespin,项目名称:Tracking-AI,代码行数:19,代码来源:RemoteController.java

示例9: editStackSize

import javax.swing.text.NumberFormatter; //导入方法依赖的package包/类
public static Dimension editStackSize(Dimension currentSize, Component parent) {
    StackSizeEditor dialog = new StackSizeEditor();
    dialog.stackDimension = currentSize;

    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);

    dialog.newHeight.setFormatterFactory(new DefaultFormatterFactory(formatter));
    dialog.newWidth.setFormatterFactory(new DefaultFormatterFactory(formatter));

    dialog.currentStackSize.setText("Stack is " + currentSize.width + "px by " + currentSize.height + "px");
    dialog.newWidth.setText(String.valueOf(currentSize.width));
    dialog.newHeight.setText(String.valueOf(currentSize.height));

    dialog.pack();
    dialog.setLocationRelativeTo(parent);
    dialog.setVisible(true);

    return dialog.stackDimension;
}
 
开发者ID:defano,项目名称:hypertalk-java,代码行数:26,代码来源:StackSizeEditor.java

示例10: IntegerEditor

import javax.swing.text.NumberFormatter; //导入方法依赖的package包/类
public IntegerEditor(int min, int max) {
    super(new JFormattedTextField());
    ftf = (JFormattedTextField) getComponent();
    minimum = new Integer(min);
    maximum = new Integer(max);

    // Set up the editor for the integer cells.
    integerFormat = NumberFormat.getIntegerInstance();
    NumberFormatter intFormatter = new NumberFormatter(integerFormat);
    intFormatter.setFormat(integerFormat);
    intFormatter.setMinimum(minimum);
    intFormatter.setMaximum(maximum);

    ftf.setFormatterFactory(new DefaultFormatterFactory(intFormatter));
    ftf.setValue(minimum);
    ftf.setHorizontalAlignment(JTextField.TRAILING);
    ftf.setFocusLostBehavior(JFormattedTextField.PERSIST);

    // React when the user presses Enter while the editor is
    // active. (Tab is handled as specified by
    // JFormattedTextField's focusLostBehavior property.)
    ftf.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "check");
    ftf.getActionMap().put("check", new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (!ftf.isEditValid()) { // The text is invalid.
                if (userSaysRevert()) { // reverted
                    ftf.postActionEvent(); // inform the editor
                }
            } else
                try { // The text is valid,
                    ftf.commitEdit(); // so use it.
                    ftf.postActionEvent(); // stop editing
                } catch (java.text.ParseException exc) {
                }
        }
    });
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:38,代码来源:IntegerEditor.java

示例11: stateChanged

import javax.swing.text.NumberFormatter; //导入方法依赖的package包/类
/** Updates the text field when the main data model is updated. */
public void stateChanged(ChangeEvent e) {
    int min = sliderModel.getMinimum();
    int max = sliderModel.getMaximum();
    double value = sliderModel.getDoubleValue();
    NumberFormatter formatter = (NumberFormatter) textField.getFormatter();

    formatter.setMinimum(new Double(min));
    formatter.setMaximum(new Double(max));
    textField.setValue(new Double(value));
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:12,代码来源:ConversionPanel.java

示例12: buildNumberTextField

import javax.swing.text.NumberFormatter; //导入方法依赖的package包/类
private static JTextField buildNumberTextField()
{
	// TODO: Verifying user input
	NumberFormatter formatter = new NumberFormatter( new DecimalFormat( "0" ) );
	formatter.setValueClass( Integer.class );
	formatter.setMinimum( Integer.MIN_VALUE );
	formatter.setMaximum( Integer.MAX_VALUE );
	formatter.setAllowsInvalid( false );

	JFormattedTextField result = new JFormattedTextField();
	result.setHorizontalAlignment( SwingConstants.RIGHT );
	result.setColumns( 10 );

	return result;
}
 
开发者ID:kartoFlane,项目名称:hiervis,代码行数:16,代码来源:HKOptionsPanel.java

示例13: createFormatter

import javax.swing.text.NumberFormatter; //导入方法依赖的package包/类
private static NumberFormatter createFormatter(int min, int max) {
   NumberFormatter nf = new NumberFormatter(NumberFormat.getInstance());
   nf.setValueClass(Integer.class);
   nf.setMinimum(min);
   nf.setMaximum(max);
   return nf;
}
 
开发者ID:pushkarkp,项目名称:twidlit,代码行数:8,代码来源:IntegerTextField.java

示例14: createUIComponents

import javax.swing.text.NumberFormatter; //导入方法依赖的package包/类
/**
 * Custom initialization code from form
 */
private void createUIComponents() {
  NumberFormat numberFormat = NumberFormat.getInstance();
  NumberFormatter formatter = new NumberFormatter(numberFormat);

  formatter.setValueClass(Integer.class);
  formatter.setMaximum(1000);
  formatter.setMinimum(1);
  formatter.setCommitsOnValidEdit(true);
  formatter.setOverwriteMode(true);

  pasteToFetch = new JFormattedTextField(formatter);
  pasteToFetch.setValue(50);
}
 
开发者ID:kennedyoliveira,项目名称:ultimate-pastebin-intellij-plugin,代码行数:17,代码来源:PasteBinConfigurationForm.java

示例15: testNumberFormatter

import javax.swing.text.NumberFormatter; //导入方法依赖的package包/类
@Test (expected = ParseException.class)
public void testNumberFormatter() throws ParseException {
    NumberFormat format = NumberFormat.getIntegerInstance();
    NumberFormatter formatter = new NumberFormatter(format);
    formatter.setMaximum(Integer.MAX_VALUE - 1);
    formatter.setMinimum(Integer.MIN_VALUE + 1);
    formatter.stringToValue(TOO_BIG_INTEGER);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:9,代码来源:NumberEditorExtTest.java


注:本文中的javax.swing.text.NumberFormatter.setMinimum方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。