Package javax.swing

Examples of javax.swing.JFormattedTextField$AbstractFormatter


        Object value = getFormattedTextField().getValue();
        return value != null ? value.getClass() : null;
    }

    private void checkCommitCondition() {
        JFormattedTextField textField = getFormattedTextField();
        if (textField.isEditValid() && commitsOnValidEdit) {
            try {
                 textField.setValue(stringToValue(textField.getText()));
            } catch (ParseException e) {
            }
        }
    }
View Full Code Here


    private void formatValue() {
        if (allowsInvalid) {
            return;
        }
        JFormattedTextField textField = getFormattedTextField();
        String text = textField.getText();
        String formattedText = getFormattedText(text);
        if (!formattedText.equals(text)) {
            int caret = textField.getCaretPosition();
            textField.setText(formattedText);
            textField.setCaretPosition(Math.min(formattedText.length(), caret));
        }
    }
View Full Code Here

        } else {
            String text = getSubstring(offset,
                                       getMaxLengthToRemove(filterBypass,
                                                            offset, length));
            filterBypass.replace(offset, text.length(), text, null);
            JFormattedTextField textField = getFormattedTextField();
            //perhaps it is temporary solution
            textField.setCaretPosition(offset);
        }
    }
View Full Code Here

        try {
            MaskFormatter fmt = new MaskFormatter("##:##:##:##");
            Font fnt = new Font(Font.MONOSPACED, Font.BOLD, 24);
           
            fmt.setPlaceholderCharacter('0');
            timeField = new JFormattedTextField(fmt);
           
            timeField.setFont(fnt);
           
            add(new RecycleButton(this), new GridBagConstraints(0, 0, 1, 1, 0.0d, 1.0d, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            add(timeField, new GridBagConstraints(GridBagConstraints.RELATIVE, 0, 1, 1, 1.0d, 1.0d, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
View Full Code Here

  public void initLayout() { 
    setLayout(null);
  }
  public void initComponents() {
    // Initialisierung
    from = new JFormattedTextField();
    to = new JFormattedTextField();
    // Farben
    from.setBackground(new Color(170, 71, 12, 255));
    to.setBackground(new Color(170, 71, 12, 255));
    from.setForeground(new Color(236, 182, 74, 255));
    to.setForeground(new Color(236, 182, 74, 255));
View Full Code Here

    panel.add(txtComments, constraints);
    constraints.gridwidth = 1;
    constraints.gridy++;

    // Maximum number of backlinks
    txtMaxMain = new JFormattedTextField(NumberFormat.getIntegerInstance());
    txtMaxMain.setFocusLostBehavior(JFormattedTextField.COMMIT);
    txtMaxMain.setColumns(4);
    if ((page != null) &&
        (page.getComment() != null) &&
        (page.getComment().getMaxMainArticles() != null)) {
      txtMaxMain.setValue(page.getComment().getMaxMainArticles());
    }
    JLabel labelMaxMain = Utilities.createJLabel(GT._("Max backlinks in Main :"));
    labelMaxMain.setLabelFor(txtMaxMain);
    labelMaxMain.setHorizontalAlignment(SwingConstants.TRAILING);
    countMain = (page != null) ? page.getBacklinksCountInMainNamespace() : null;
    JLabel labelMain = new JLabel((countMain != null) ? "/ " + countMain.toString() : "");
    labelMain.setHorizontalAlignment(SwingConstants.LEADING);
    buttonCopyMaxMain = Utilities.createJButton("\u21D0", null);
    buttonCopyMaxMain.addActionListener(EventHandler.create(
        ActionListener.class, this, "actionCopyMain"));
    buttonCopyMaxMain.setEnabled(countMain != null);
    constraints.gridx = 0;
    constraints.weightx = 0;
    panel.add(labelMaxMain, constraints);
    constraints.gridx++;
    constraints.weightx = 0;
    panel.add(txtMaxMain, constraints);
    constraints.gridx++;
    constraints.weightx = 0;
    panel.add(buttonCopyMaxMain, constraints);
    constraints.gridx++;
    constraints.weightx = 1;
    panel.add(labelMain, constraints);
    constraints.gridy++;

    txtMaxTemplate = new JFormattedTextField(NumberFormat.getIntegerInstance());
    txtMaxTemplate.setFocusLostBehavior(JFormattedTextField.COMMIT);
    txtMaxTemplate.setColumns(4);
    if ((page != null) &&
        (page.getComment() != null) &&
        (page.getComment().getMaxTemplateArticles() != null)) {
      txtMaxTemplate.setValue(page.getComment().getMaxTemplateArticles());
    }
    JLabel labelMaxTemplate = Utilities.createJLabel(GT._("Max backlinks in Template :"));
    labelMaxTemplate.setLabelFor(txtMaxTemplate);
    labelMaxTemplate.setHorizontalAlignment(SwingConstants.TRAILING);
    countTemplate = (page != null) ? page.getBacklinksCountInTemplateNamespace() : null;
    JLabel labelTemplate = new JLabel((countTemplate != null) ? "/ " + countTemplate.toString() : "");
    labelTemplate.setHorizontalAlignment(SwingConstants.LEADING);
    buttonCopyMaxTemplate = Utilities.createJButton("\u21D0", null);
    buttonCopyMaxTemplate.addActionListener(EventHandler.create(
        ActionListener.class, this, "actionCopyTemplate"));
    buttonCopyMaxTemplate.setEnabled(countTemplate != null);
    constraints.gridx = 0;
    constraints.weightx = 0;
    panel.add(labelMaxTemplate, constraints);
    constraints.gridx++;
    constraints.weightx = 0;
    panel.add(txtMaxTemplate, constraints);
    constraints.gridx++;
    constraints.weightx = 0;
    panel.add(buttonCopyMaxTemplate, constraints);
    constraints.gridx++;
    constraints.weightx = 1;
    panel.add(labelTemplate, constraints);
    constraints.gridy++;

    txtMaxOther = new JFormattedTextField(NumberFormat.getIntegerInstance());
    txtMaxOther.setFocusLostBehavior(JFormattedTextField.COMMIT);
    txtMaxOther.setColumns(4);
    if ((page != null) &&
        (page.getComment() != null) &&
        (page.getComment().getMaxOtherArticles() != null)) {
View Full Code Here

    private void createGraphDemo() {
        JPanel controlPanel = new JPanel();
        JLabel label = new JLabel("y = ");
        controlPanel.add(label);

        formula = new JFormattedTextField(NumberFormat.getNumberInstance());
        formula.setName("formula");
        formula.setValue(1.0);
        controlPanel.add(formula);

        label = new JLabel("x");
View Full Code Here

    }
   
    if (component instanceof JTextComponent) {
        if ( component instanceof JFormattedTextField ){
        try {
          JFormattedTextField field = ((JFormattedTextField)component);
          field.requestFocus();
          field.setText(value);
          //launch an exception for invalid input
          field.commitEdit();
          //lose focus to format the value
          forceToLooseFocus(component);
          } catch (ParseException e) {
            // Invalid value in field
            //return false;
View Full Code Here

   */
  public void setSpinnerBackground(Color bg) {
      JComponent editor = getEditor();
      if (editor instanceof JSpinner.DefaultEditor) {
        JSpinner.DefaultEditor defEditor = (JSpinner.DefaultEditor) editor;
        JFormattedTextField tf = defEditor.getTextField();
        if (tf != null) {
          tf.setBackground(bg);
        }
      }
  }
View Full Code Here

            private static final long serialVersionUID = 1L;
            //            boolean getSupportsIncrement() {
            //                return super.getStrue;
            //            }
        };
        ftf = new JFormattedTextField();
        bWasException = false;
    }
View Full Code Here

TOP

Related Classes of javax.swing.JFormattedTextField$AbstractFormatter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.