Java Code Examples for javax.swing.text.Segment#setPartialReturn()
The following examples show how to use
javax.swing.text.Segment#setPartialReturn() .
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: OverviewControllerUI.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void getText(int offset, int length, Segment txt) throws BadLocationException { if (lastOffset == offset && lastLength == length) { txt.array = segArray; txt.offset = segOffset; txt.count = segCount; txt.setPartialReturn(segPartialReturn); return; } super.getText(offset, length, txt); if (length > CACHE_BOUNDARY || lastLength <= CACHE_BOUNDARY) { segArray = txt.array; segOffset = txt.offset; segCount = txt.count; segPartialReturn = txt.isPartialReturn(); lastOffset = offset; lastLength = length; } }
Example 2
Source File: ThreadDumpWindow.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void getText(int offset, int length, Segment txt) throws BadLocationException { if (lastOffset == offset && lastLength == length) { txt.array = segArray; txt.offset = segOffset; txt.count = segCount; txt.setPartialReturn(segPartialReturn); return; } super.getText(offset, length, txt); if (length > CACHE_BOUNDARY || lastLength <= CACHE_BOUNDARY) { segArray = txt.array; segOffset = txt.offset; segCount = txt.count; segPartialReturn = txt.isPartialReturn(); lastOffset = offset; lastLength = length; } }
Example 3
Source File: HTMLTextComponent.java From visualvm with GNU General Public License v2.0 | 6 votes |
public void getText(int offset, int length, Segment txt) throws BadLocationException { if (lastOffset == offset && lastLength == length) { txt.array = segArray; txt.offset = segOffset; txt.count = segCount; txt.setPartialReturn(segPartialReturn); return; } super.getText(offset, length, txt); if (length > CACHE_BOUNDARY || lastLength <= CACHE_BOUNDARY) { segArray = txt.array; segOffset = txt.offset; segCount = txt.count; segPartialReturn = txt.isPartialReturn(); lastOffset = offset; lastLength = length; } }
Example 4
Source File: OverviewControllerUI.java From visualvm with GNU General Public License v2.0 | 6 votes |
@Override public void getText(int offset, int length, Segment txt) throws BadLocationException { if (lastOffset == offset && lastLength == length) { txt.array = segArray; txt.offset = segOffset; txt.count = segCount; txt.setPartialReturn(segPartialReturn); return; } super.getText(offset, length, txt); if (length > CACHE_BOUNDARY || lastLength <= CACHE_BOUNDARY) { segArray = txt.array; segOffset = txt.offset; segCount = txt.count; segPartialReturn = txt.isPartialReturn(); lastOffset = offset; lastLength = length; } }
Example 5
Source File: ThreadDumpWindow.java From visualvm with GNU General Public License v2.0 | 6 votes |
@Override public void getText(int offset, int length, Segment txt) throws BadLocationException { if (lastOffset == offset && lastLength == length) { txt.array = segArray; txt.offset = segOffset; txt.count = segCount; txt.setPartialReturn(segPartialReturn); return; } super.getText(offset, length, txt); if (length > CACHE_BOUNDARY || lastLength <= CACHE_BOUNDARY) { segArray = txt.array; segOffset = txt.offset; segCount = txt.count; segPartialReturn = txt.isPartialReturn(); lastOffset = offset; lastLength = length; } }
Example 6
Source File: ThreadDumpView.java From visualvm with GNU General Public License v2.0 | 6 votes |
@Override public void getText(int offset, int length, Segment txt) throws BadLocationException { if (lastOffset == offset && lastLength == length) { txt.array = segArray; txt.offset = segOffset; txt.count = segCount; txt.setPartialReturn(segPartialReturn); return; } super.getText(offset, length, txt); if (length > CACHE_BOUNDARY || lastLength <= CACHE_BOUNDARY) { segArray = txt.array; segOffset = txt.offset; segCount = txt.count; segPartialReturn = txt.isPartialReturn(); lastOffset = offset; lastLength = length; } }
Example 7
Source File: DocumentCharacterIterator.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
DocumentCharacterIterator(Document doc) { this.doc = doc; text = new Segment(); text.setPartialReturn(true); try { doc.getText(0, doc.getLength(), text); } catch (BadLocationException e) { throw new RuntimeException(e); } segmentEnd = text.count; }
Example 8
Source File: MainView.java From HiJson with Apache License 2.0 | 4 votes |
/** * 文本内容查找定位 * @param key 要查找的字符串 * @param ignoreCase 是否区分大小写 * @param down 查找方向(向上false,向下true) * @param isFirst 是否从开头开始查找 * @return */ public boolean startSegmentFindOrReplaceOperation(JTextArea textArea, String key, boolean ignoreCase, boolean down,boolean isFirst) { int length = key.length(); Document doc = textArea.getDocument(); int offset = textArea.getCaretPosition(); int charsLeft = doc.getLength() - offset; if(charsLeft <=0 ){ offset = 0; charsLeft = doc.getLength() - offset; } if (!down) { offset -= length; offset--; charsLeft = offset; } if(isFirst){ offset = 0; charsLeft = doc.getLength() - offset; } Segment text = new Segment(); text.setPartialReturn(true); try { while (charsLeft > 0) { doc.getText(offset, length, text); if ((ignoreCase == true && text.toString().equalsIgnoreCase(key)) || (ignoreCase == false && text.toString().equals(key))) { textArea.requestFocus();////焦点,才能能看到效果 textArea.setSelectionStart(offset); textArea.setSelectionEnd(offset + length); return true; } charsLeft--; if (down) { offset++; } else { offset--; } } } catch (Exception e) { } return false; }