Java Code Examples for javax.swing.text.DocumentFilter#FilterBypass
The following examples show how to use
javax.swing.text.DocumentFilter#FilterBypass .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JConsole.java From opensim-gui with Apache License 2.0 | 6 votes |
@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); } }
Example 2
Source File: JConsole.java From opensim-gui with Apache License 2.0 | 6 votes |
@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); } }
Example 3
Source File: IntegerDocumentFilter.java From Explvs-AIO with MIT License | 5 votes |
@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); }
Example 4
Source File: SmartDocumentFilter.java From groovy with Apache License 2.0 | 5 votes |
@Override public void remove(DocumentFilter.FilterBypass fb, int offset, int length) throws BadLocationException { fb.remove(offset, length); parseDocument(); }
Example 5
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
@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; } }
Example 6
Source File: RuneliteColorPicker.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
/** * 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(); }
Example 7
Source File: IntegerDocumentFilter.java From mts with GNU General Public License v3.0 | 5 votes |
@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); }
Example 8
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
@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); }
Example 9
Source File: PollIntervalDialog.java From sql-developer-keepalive with MIT License | 5 votes |
@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(); } }
Example 10
Source File: IntegerDocumentFilter.java From Explvs-AIO with MIT License | 5 votes |
@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); }
Example 11
Source File: DoubleDocumentFilter.java From Explvs-AIO with MIT License | 5 votes |
@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); }
Example 12
Source File: DoubleDocumentFilter.java From Explvs-AIO with MIT License | 5 votes |
@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); }
Example 13
Source File: MainPanel.java From java-swing-tips with MIT License | 4 votes |
@Override public void remove(DocumentFilter.FilterBypass fb, int offset, int length) throws BadLocationException { replace(fb, offset, length, "", null); }
Example 14
Source File: BaseDocument.java From netbeans with Apache License 2.0 | 4 votes |
private DocumentFilter.FilterBypass getFilterBypass() { if (filterBypass == null) { filterBypass = new FilterBypassImpl(); } return filterBypass; }
Example 15
Source File: CoordinateFormatter.java From dsworkbench with Apache License 2.0 | 4 votes |
@Override public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException { fb.replace(offset, length, text, attrs); }
Example 16
Source File: MainPanel.java From java-swing-tips with MIT License | 4 votes |
@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); } }
Example 17
Source File: MainPanel.java From java-swing-tips with MIT License | 4 votes |
@Override public void remove(DocumentFilter.FilterBypass fb, int offset, int length) throws BadLocationException { fb.remove(offset, length); }
Example 18
Source File: ConsoleModel.java From netbeans with Apache License 2.0 | 4 votes |
public DocumentFilter.FilterBypass getProtectionBypass() { return bypass; }
Example 19
Source File: MainPanel.java From java-swing-tips with MIT License | 4 votes |
@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); } }
Example 20
Source File: MainPanel.java From java-swing-tips with MIT License | 4 votes |
@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); } }