javax.swing.text.DocumentFilter#FilterBypass ( )源码实例Demo

下面列出了javax.swing.text.DocumentFilter#FilterBypass ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: opensim-gui   文件: JConsole.java
@Override
public void insertString(DocumentFilter.FilterBypass fb, int offset, String string, AttributeSet attr)
        throws BadLocationException {
    if (useFilters) {
        // determine if we can insert
        if (console.getSelectionStart() >= console.editStart) {
            // can insert
            fb.insertString(offset, string, attr);
        } else {
            // insert at the end of the document
            fb.insertString(console.getText().length(), string, attr);
            // move cursor to the end
            console.getCaret().setDot(console.getText().length());
            // console.setSelectionEnd(console.getText().length());
            // console.setSelectionStart(console.getText().length());
        }
    } else {
        fb.insertString(offset, string, attr);
    }
}
 
源代码2 项目: opensim-gui   文件: JConsole.java
@Override
public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String text, AttributeSet attrs)
        throws BadLocationException {
    if (useFilters) {
        // determine if we can replace
        if (console.getSelectionStart() >= console.editStart) {
            // can replace
            fb.replace(offset, length, text, attrs);
        } else {
            // insert at end
            fb.insertString(console.getText().length(), text, attrs);
            // move cursor to the end
            console.getCaret().setDot(console.getText().length());
            // console.setSelectionEnd(console.getText().length());
            // console.setSelectionStart(console.getText().length());
        }
    } else {
        fb.replace(offset, length, text, attrs);
    }
}
 
源代码3 项目: Explvs-AIO   文件: DoubleDocumentFilter.java
@Override
public void replace(DocumentFilter.FilterBypass fb,
                    int offset,
                    int length,
                    String text,
                    AttributeSet attrs) throws BadLocationException {

    Matcher matcher = DOUBLE_REGEX.matcher(text);

    if (!matcher.matches()) {
        return;
    }

    super.replace(fb, offset, length, text, attrs);
}
 
源代码4 项目: Explvs-AIO   文件: IntegerDocumentFilter.java
@Override
public void replace(DocumentFilter.FilterBypass fb,
                    int offset,
                    int length,
                    String text,
                    AttributeSet attrs) throws BadLocationException {

    Matcher matcher = NUMBER_REGEX.matcher(text);

    if (!matcher.matches()) {
        return;
    }

    super.replace(fb, offset, length, text, attrs);
}
 
源代码5 项目: Explvs-AIO   文件: DoubleDocumentFilter.java
@Override
public void replace(DocumentFilter.FilterBypass fb,
                    int offset,
                    int length,
                    String text,
                    AttributeSet attrs) throws BadLocationException {

    Matcher matcher = DOUBLE_REGEX.matcher(text);

    if (!matcher.matches()) {
        return;
    }

    super.replace(fb, offset, length, text, attrs);
}
 
源代码6 项目: Explvs-AIO   文件: IntegerDocumentFilter.java
@Override
public void replace(DocumentFilter.FilterBypass fb,
                    int offset,
                    int length,
                    String text,
                    AttributeSet attrs) throws BadLocationException {

    Matcher matcher = NUMBER_REGEX.matcher(text);

    if (!matcher.matches()) {
        return;
    }

    super.replace(fb, offset, length, text, attrs);
}
 
@Override
public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String text,
                    AttributeSet attrs) throws BadLocationException {
    if (isNumber(text))
        super.replace(fb, offset, length, text, attrs);
    else {
        java.awt.Toolkit.getDefaultToolkit().beep();
    }
}
 
源代码8 项目: java-swing-tips   文件: MainPanel.java
@Override public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
  int len = fb.getDocument().getLength();
  if (len - length + text.length() > MAX) {
    Toolkit.getDefaultToolkit().beep();
    return;
  }
  fb.replace(offset, length, text, attrs);
}
 
源代码9 项目: mts   文件: IntegerDocumentFilter.java
@Override
public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
    String intToReplace;
    if (!Utils.isInteger(text)){
        intToReplace = "";
    }
    else{
        intToReplace = text;
    }
    super.replace(fb, offset, length, intToReplace, attrs);
}
 
源代码10 项目: runelite   文件: RuneliteColorPicker.java
/**
 * Gets the whole string from the passed DocumentFilter replace.
 */
static String getReplacedText(DocumentFilter.FilterBypass fb, int offset, int length, String str)
	throws BadLocationException
{
	Document doc = fb.getDocument();
	StringBuilder sb = new StringBuilder(doc.getText(0, doc.getLength()));
	sb.replace(offset, offset + length, str);

	return sb.toString();
}
 
源代码11 项目: java-swing-tips   文件: MainPanel.java
@Override public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
  if (length == 0) {
    fb.insertString(offset, text, attrs);
  } else {
    compoundEdit = new CompoundEdit();
    fb.replace(offset, length, text, attrs);
    compoundEdit.end();
    addEdit(compoundEdit);
    compoundEdit = null;
  }
}
 
源代码12 项目: groovy   文件: SmartDocumentFilter.java
@Override
public void remove(DocumentFilter.FilterBypass fb, int offset, int length)
        throws BadLocationException {

    fb.remove(offset, length);
    parseDocument();
}
 
源代码13 项目: netbeans   文件: ConsoleModel.java
public DocumentFilter.FilterBypass getProtectionBypass() {
    return bypass;
}
 
源代码14 项目: java-swing-tips   文件: MainPanel.java
@Override public void remove(DocumentFilter.FilterBypass fb, int offset, int length) throws BadLocationException {
  replace(fb, offset, length, "", null);
}
 
源代码15 项目: netbeans   文件: BaseDocument.java
private DocumentFilter.FilterBypass getFilterBypass() {
    if (filterBypass == null) {
        filterBypass = new FilterBypassImpl();
    }
    return filterBypass;
}
 
源代码16 项目: dsworkbench   文件: CoordinateFormatter.java
@Override
public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String text,
        AttributeSet attrs) throws BadLocationException {
    fb.replace(offset, length, text, attrs);
}
 
源代码17 项目: java-swing-tips   文件: MainPanel.java
@Override public void insertString(DocumentFilter.FilterBypass fb, int offset, String text, AttributeSet attr) throws BadLocationException {
  if (Objects.nonNull(text)) {
    replace(fb, offset, 0, text, attr);
  }
}
 
源代码18 项目: java-swing-tips   文件: MainPanel.java
@Override public void remove(DocumentFilter.FilterBypass fb, int offset, int length) throws BadLocationException {
  fb.remove(offset, length);
}
 
源代码19 项目: java-swing-tips   文件: MainPanel.java
@Override public void insertString(DocumentFilter.FilterBypass fb, int offset, String text, AttributeSet attr) throws BadLocationException {
  if (Objects.nonNull(text)) {
    replace(fb, offset, 0, text, attr);
  }
}
 
源代码20 项目: java-swing-tips   文件: MainPanel.java
@Override public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
  Document doc = fb.getDocument();
  if (doc.getDefaultRootElement().getElementIndex(offset) >= maskRange) {
    fb.replace(offset, length, text, attrs);
  }
}
 
 同类方法