public void insertString(DocumentFilter.FilterBypass fb, int offs, String str, AttributeSet a)
     throws BadLocationException {
   if (isValidPostiveNumber(true, fb, offs, str, 0)) {
     fb.insertString(offs, str, a);
     doValueUpdate(fb);
   }
 } // End of insert
Esempio n. 2
0
 /** {@inheritDoc} */
 public void insertString(
     DocumentFilter.FilterBypass fb, int offset, String text, AttributeSet attr)
     throws BadLocationException {
   int previousLength = fb.getDocument().getLength();
   fb.insertString(offset, text.replaceAll("[^0-9]", ""), attr);
   trimPosition(fb, text, offset, previousLength);
 }
Esempio n. 3
0
  /** {@inheritDoc} */
  public void replace(
      DocumentFilter.FilterBypass fb, int offset, int length, String text, AttributeSet attr)
      throws BadLocationException {
    int previousLength = fb.getDocument().getLength();

    String t = fb.getDocument().getText(offset, length);
    int index = t.indexOf(":");
    fb.replace(offset, length, text.replaceAll("[^0-9]", ""), attr);
    if (index != -1) {
      if (fb.getDocument().getLength() >= 2) {
        fb.insertString(2, ":", attr);
      } else {
        fb.insertString(fb.getDocument().getLength(), ":", attr);
      }
    }

    trimPosition(fb, text, offset, previousLength);
  }
 public void insertString(
     DocumentFilter.FilterBypass filtby, int ofs, String text, AttributeSet attrSet)
     throws BadLocationException {
   if (filtby.getDocument().getLength() + text.length() <= maxLength) {
     filtby.insertString(ofs, text, attrSet);
   } else {
     Toolkit.getDefaultToolkit().beep();
   }
 }
Esempio n. 5
0
 public void insertString(
     DocumentFilter.FilterBypass fb, int offset, String text, AttributeSet attr)
     throws BadLocationException {
   fb.insertString(offset, text.toUpperCase(), attr);
 }