コード例 #1
0
    public void insertString(FilterBypass fb, int offs, String str, AttributeSet a)
        throws BadLocationException {
      if ("\n".equals(str)) {
        str = addWhiteSpace(fb.getDocument(), offs);
        if (fb.getDocument().getText(offs - 2, 1).equals("{")) {
          str = str + "Meow";
        }
      }

      super.insertString(fb, offs, str, a);
    }
コード例 #2
0
ファイル: NumbrixGUI.java プロジェクト: rainerlg90/Numbrix
    @Override
    public void replace(
        DocumentFilter.FilterBypass fp, int offset, int length, String string, AttributeSet aset)
        throws BadLocationException {
      Document doc = fp.getDocument();
      String oldText = doc.getText(0, doc.getLength());
      StringBuilder sb = new StringBuilder(oldText);
      sb.replace(offset, offset + length, oldText);

      int len = string.length();
      boolean isValidInteger = true;

      for (int i = 0; i < len; i++) {
        if (!Character.isDigit(string.charAt(i))) {
          isValidInteger = false;
          break;
        }
      }
      if (isValidInteger && verifyText(sb.toString())) {
        super.replace(fp, offset, length, string, aset);
      } else Toolkit.getDefaultToolkit().beep();
    }
コード例 #3
0
    public void replace(FilterBypass fb, int offs, int length, String str, AttributeSet a)
        throws BadLocationException {
      if ("\n".equals(str)) str = addWhiteSpace(fb.getDocument(), offs);

      super.replace(fb, offs, length, str, a);
    }