Package javax.swing

Examples of javax.swing.JFormattedTextField$CancelAction


        super.tearDown();
    }

    public void testCreateUIJComponent() {
        assertTrue(BasicFormattedTextFieldUI.createUI(null) instanceof BasicFormattedTextFieldUI);
        assertTrue(BasicFormattedTextFieldUI.createUI(new JFormattedTextField()) instanceof BasicFormattedTextFieldUI);
    }
View Full Code Here


            month = new SpinnerListModel(MONTH_STRINGS);
            month.setValue(MONTH_STRINGS[cal.get(Calendar.MONTH)]);
            JSpinner monthSpinner = new JSpinner(month);
            JComponent editor = monthSpinner.getEditor();
            if (editor instanceof JSpinner.DefaultEditor) {
                JFormattedTextField tf = ((JSpinner.DefaultEditor) editor).getTextField();
                tf.setColumns(6);
                tf.setHorizontalAlignment(JTextField.RIGHT);
            }
            addSpinner(monthSpinner, status);

            year = new SpinnerNumberModel(cal.get(Calendar.YEAR), 0, 9999, 1);
            JSpinner yearSpinner = new JSpinner(year);
View Full Code Here

        createRow("File:", filePanel, 3);

        JPanel generateContentPanel = new JPanel();
        generateContentPanel.setLayout(new BoxLayout(generateContentPanel, BoxLayout.X_AXIS));

        generateContentSizeField = new JFormattedTextField(NumberFormat.getIntegerInstance());
        generateContentSizeField.setValue(0L);
        generateContentSizeField.setColumns(8);
        generateContentSizeField.setHorizontalAlignment(JTextField.RIGHT);
        generateContentSizeField.setMaximumSize(generateContentSizeField.getPreferredSize());
        generateContentPanel.add(generateContentSizeField);
View Full Code Here

        createRow("File:", filePanel, 3);

        JPanel generateContentPanel = new JPanel();
        generateContentPanel.setLayout(new BoxLayout(generateContentPanel, BoxLayout.X_AXIS));

        generateContentSizeField = new JFormattedTextField(NumberFormat.getIntegerInstance());
        generateContentSizeField.setValue(0L);
        generateContentSizeField.setColumns(8);
        generateContentSizeField.setHorizontalAlignment(JTextField.RIGHT);
        generateContentSizeField.setMaximumSize(generateContentSizeField.getPreferredSize());
        generateContentPanel.add(generateContentSizeField);
View Full Code Here

        setTitleMsgNumber(TitleMsgNum.intValue());
    }

    public ArrayColumn(int alignment, int maxCharacters, TextData Name, int sizePolicy, int state, TextData title) {
        super();
        int width = UIutils.colsToPixels(maxCharacters, new JFormattedTextField());
        this.assignedWidth = width;
        this.setWidth(width);
        this.setMinWidth(width);
       
        if ((Name == null) || Name.isEqual("").getBooleanValue())
View Full Code Here

//            }
//        });
    }
   
    public PasswordCellEditor(AbstractFormatter formatter) {
        super(new JFormattedTextField(formatter));
        df = (JFormattedTextField)getComponent();
        df.setFocusLostBehavior(JFormattedTextField.PERSIST);
    }
View Full Code Here

        super(new JFormattedTextField(formatter));
        df = (JFormattedTextField)getComponent();
        df.setFocusLostBehavior(JFormattedTextField.PERSIST);
    }
    public PasswordCellEditor(AbstractFormatterFactory factory) {
        super(new JFormattedTextField(factory));
        df = (JFormattedTextField)getComponent();
    }
View Full Code Here

        setTitleMsgNumber(TitleMsgNum.intValue());
    }

    public ArrayColumn(int alignment, int maxCharacters, TextData Name, int sizePolicy, int state, TextData title) {
        super();
        int width = UIutils.colsToPixels(maxCharacters, new JFormattedTextField());
        this.assignedWidth = width;
        this.setWidth(width);
        this.setMinWidth(width);
       
        if ((Name == null) || Name.isEqual("").getBooleanValue())
View Full Code Here

          // System.out.println("Initial text = " + text);
//          String charsToRemove;
          // If the user is trying to backspace over a special character, like a comma, we don't
          // allow it, but instead move to the previous number. This only applies if the dot and mark
          // of the filter are the same (ie, they don't have a highlighted selection)
          JFormattedTextField comp = this.field;
          if (length == 1 && comp.getCaret().getDot() == comp.getCaret().getMark()) {
            while (offset >= 0 && !Character.isDigit(text.charAt(offset))) {
              offset--;
            }
            if (offset < 0) {
              // Nothing to do
              return;
            }
//            else {
//              charsToRemove = text.substring(offset, offset + length);
//            }
          }
//          else {
//             charsToRemove = text.substring(offset, offset + length);
//          }
          // System.out.println("Chars to remove = " + charsToRemove);
          try {
          Object o = comp.getFormatter().stringToValue(text);
          String value = text;
          // TF:11/04/2008: Check for null coming back in case it's a widget mapped to
          // a nullable field with a null value
          if (o != null) {
            value = o.toString();
            // System.out.println(o.toString() + " - " + o.getClass().toString());
            char[] chars = text.toCharArray();
            int srcIndex = offset-1;
            int destIndex = offset + length-1;
            while (destIndex >= 0) {
              if (Character.isDigit(chars[destIndex])) {
                //need to replace this digit with another one
                while (srcIndex >= 0 && !Character.isDigit(chars[srcIndex])) {
                  srcIndex--;
                }
                if (srcIndex >= 0) {
                  // Replace this index with the source digit
                  chars[destIndex] = chars[srcIndex];
                  // Now drop the source index back one
                  srcIndex--;
                }
                else {
                  // No character, must replace with 0
                  chars[destIndex] = '0';
                }
              }
              destIndex--;
            }
            // System.out.println("Current dot at:" + this.field.getCaret().getDot());
            // System.out.println("Current mark at:" + this.field.getCaret().getMark());
            // System.out.println("New value = " + new String(chars));
            o = comp.getFormatter().stringToValue(new String(chars));
          }
          value = comp.getFormatter().valueToString(o);
              int lengthToReplace = getReplaceToOffset(text, value);
             
              lengthToReplace = Math.max(length + offset, lengthToReplace);
              // System.out.println("new value = " + value);
              // System.out.println("replacement length(" + text + ", " + value + ") = " + lengthToReplace);
View Full Code Here

//            }
//        });
    }
   
    public FormattedCellEditor(AbstractFormatter formatter) {
        super(new JFormattedTextField(formatter));
        df = (JFormattedTextField)getComponent();
        df.setFocusLostBehavior(JFormattedTextField.PERSIST);
    }
View Full Code Here

TOP

Related Classes of javax.swing.JFormattedTextField$CancelAction

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.