當前位置: 首頁>>代碼示例>>Java>>正文


Java NumberFormatter.setAllowsInvalid方法代碼示例

本文整理匯總了Java中javax.swing.text.NumberFormatter.setAllowsInvalid方法的典型用法代碼示例。如果您正苦於以下問題:Java NumberFormatter.setAllowsInvalid方法的具體用法?Java NumberFormatter.setAllowsInvalid怎麽用?Java NumberFormatter.setAllowsInvalid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.text.NumberFormatter的用法示例。


在下文中一共展示了NumberFormatter.setAllowsInvalid方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例5: 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

示例6: createUIComponents

import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
private void createUIComponents() {
    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);
    portTextField = new JFormattedTextField(formatter);
    jvmPortTextField = new JFormattedTextField(formatter);

    appsMap = new JBTable(new ModulesTableModel());

}
 
開發者ID:machaval,項目名稱:mule-intellij-plugins,代碼行數:15,代碼來源:MuleRemoteDebuggerConfPanel.java

示例7: 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

示例8: getPortValueFormatter

import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
private NumberFormatter getPortValueFormatter() {
    NumberFormat plainIntegerFormat = NumberFormat.getInstance();
    plainIntegerFormat.setGroupingUsed(false);                      // no commas

    NumberFormatter portFormatter = new NumberFormatter(plainIntegerFormat);
    portFormatter.setValueClass(Integer.class);
    portFormatter.setAllowsInvalid(false);
    portFormatter.setMinimum(0);
    portFormatter.setMaximum(65535);
    return portFormatter;
}
 
開發者ID:yawlfoundation,項目名稱:yawl,代碼行數:12,代碼來源:PreferencesDialog.java

示例9: createImageExportWidthPanel

import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
private void createImageExportWidthPanel() {
	imageExportWidth = new JFormattedTextField();
	NumberFormat longFormat = NumberFormat.getIntegerInstance();
	longFormat.setGroupingUsed(false);

	NumberFormatter numberFormatter = new NumberFormatter(longFormat);
	numberFormatter.setAllowsInvalid(false);
	numberFormatter.setMinimum(0);
	numberFormatter.setMaximum(9999);

	imageExportWidth = new JFormattedTextField(numberFormatter);
	dialog.add(new JLabel("Image initial width [px]"));
	dialog.add(imageExportWidth, "wrap");
}
 
開發者ID:mnikliborc,項目名稱:clicktrace,代碼行數:15,代碼來源:SettingsView.java

示例10: IntInput

import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
public IntInput(Question question, Value<?> value) {
	mf = new NumberFormatter(NumberFormat.getIntegerInstance());
	mf.setAllowsInvalid(false);
	widget = new JFormattedTextField(mf);
	widget.setColumns(10);
	widget.setName(question.getIdent().getName());
	setValue(value);
}
 
開發者ID:software-engineering-amsterdam,項目名稱:poly-ql,代碼行數:9,代碼來源:IntInput.java

示例11: configureFormatter

import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
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;
}
 
開發者ID:sing-group,項目名稱:GC4S,代碼行數:12,代碼來源:JIntegerTextField.java

示例12: initializeTextFields

import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
private void initializeTextFields() throws ParseException {

		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.txtCapacidade = new JFormattedTextField(formatter);
		this.txtCapacidade.setValue(0.0);

		GridBagConstraints gbc_textField = new GridBagConstraints();
		gbc_textField.insets = new Insets(0, 0, 5, 5);
		gbc_textField.fill = GridBagConstraints.HORIZONTAL;
		gbc_textField.gridx = 3;
		gbc_textField.gridy = 13;
		this.panel.add(this.txtCapacidade, gbc_textField);
		this.txtCapacidade.setColumns(10);

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

		GridBagConstraints gbc_textField_1 = new GridBagConstraints();
		gbc_textField_1.insets = new Insets(0, 0, 5, 5);
		gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
		gbc_textField_1.gridx = 3;
		gbc_textField_1.gridy = 18;
		this.panel.add(this.txtCusto, gbc_textField_1);
		this.txtCusto.setColumns(10);

		this.txtTempo = new JFormattedTextField();
		this.txtTempo.addKeyListener(new KeyAdapter(){
			@Override
			public void keyTyped(KeyEvent e){
				String numbers = "0123456789";
				if(!numbers.contains(e.getKeyChar() + ""))
					e.consume();
			}	
		});
		
		GridBagConstraints gbc_textField_2 = new GridBagConstraints();
		gbc_textField_2.insets = new Insets(0, 0, 5, 5);
		gbc_textField_2.fill = GridBagConstraints.HORIZONTAL;
		gbc_textField_2.gridx = 3;
		gbc_textField_2.gridy = 23;
		this.panel.add(this.txtTempo, gbc_textField_2);
		this.txtTempo.setColumns(10);
	}
 
開發者ID:cjlcarvalho,項目名稱:LogisticApp,代碼行數:54,代碼來源:DiretaPanelBuilder.java


注:本文中的javax.swing.text.NumberFormatter.setAllowsInvalid方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。