JTextComponent editor = ((JTextField) myComboBox.getEditor().getEditorComponent()); editor.setCaretPosition(getLength()); editor.moveCaretPosition(0);
@Override public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) { try { target.moveCaretPosition(SmartHomeAction.getSmartHomeOffset(target, sDoc, dot)); } catch (BadLocationException ex) { Logger.getLogger(SmartHomeSelectAction.class.getName()).log(Level.SEVERE, null, ex); } } }
@Override public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) { try { target.moveCaretPosition(SmartHomeAction.getSmartHomeOffset(target, sDoc, dot)); } catch (BadLocationException ex) { Logger.getLogger(SmartHomeSelectAction.class.getName()).log(Level.SEVERE, null, ex); } } }
public void run() { tc.setCaretPosition(0); tc.moveCaretPosition(0); } });
@Override public void focusGained(final FocusEvent e) { final JTextComponent tc = ((JTextComponent) e.getComponent()); tc.setCaretPosition(tc.getText().length()); tc.moveCaretPosition(0); } };
@RunsInCurrentThread static void selectTextInRange(@Nonnull JTextComponent textBox, int start, int end) { textBox.setCaretPosition(start); textBox.moveCaretPosition(end); }
private void highlightCompletedText(final int pStart) { mEditor.setCaretPosition(getLength()); mEditor.moveCaretPosition(pStart); }
private void highlightCompletedText(final int start) { editor.setCaretPosition(getLength()); editor.moveCaretPosition(start); }
/** * Marks/selects the text that is displayed inside the text component starting from the * character with index <tt>start</tt>. * @param start index of the first character that should be marked */ public void markText(int start) { getTextComponent().setCaretPosition(getTextComponent().getText().length()); getTextComponent().moveCaretPosition(start); } }
private void highlightCompletedText(int start) { int length = getTextComponent().getDocument().getLength(); getTextComponent().setCaretPosition(length); if (start < 0) { start = 0; } if (start > length) { start = length; } getTextComponent().moveCaretPosition(start); }
/** * Marks/selects the text that is displayed inside the text component starting from the * character with index <tt>start</tt>. * @param start index of the first character that should be marked */ public void markText(int start) { getTextComponent().setCaretPosition(getTextComponent().getText().length()); getTextComponent().moveCaretPosition(start); } }
/** * Marks/selects the text that is displayed inside the text component starting from the * character with index <tt>start</tt>. * @param start index of the first character that should be marked */ public void markText(int start) { getTextComponent().setCaretPosition(getTextComponent().getText().length()); getTextComponent().moveCaretPosition(start); } }
/** * Highlights Completed Text, so that it is clear which text was entered * by the user, and which text was auto-completed. * * @param start start index. */ private void highlightCompletedText(int start) { debug("highlightCompletedText, start= " + start); editor.setCaretPosition(getLength()); editor.moveCaretPosition(start); }
public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { super.insertString(offs, str, a); String word = autoComplete(getText(0, getLength())); if (word != null) { super.insertString(offs + str.length(), word, a); comp.setCaretPosition(offs + str.length()); comp.moveCaretPosition(getLength()); } }
protected void highlight(JTextComponent comp, int i, int j, boolean scroll) { Highlighter highlighter = comp.getHighlighter(); highlighter.removeAllHighlights(); try { i = toComponentPosition(comp, i); j = toComponentPosition(comp, j); highlighter.addHighlight(i, j+1, DefaultHighlighter.DefaultPainter); if (scroll) { if (comp.getCaretPosition() < i || comp.getCaretPosition() > j) { comp.moveCaretPosition(i); comp.scrollRectToVisible(comp.modelToView(i)); } } } catch (BadLocationException ble) { errMgr.internalError(tmodel.root.event.scope.st, "bad highlight location", ble); } }
protected void highlight(JTextComponent comp, int i, int j, boolean scroll) { Highlighter highlighter = comp.getHighlighter(); highlighter.removeAllHighlights(); try { i = toComponentPosition(comp, i); j = toComponentPosition(comp, j); highlighter.addHighlight(i, j+1, DefaultHighlighter.DefaultPainter); if (scroll) { if (comp.getCaretPosition() < i || comp.getCaretPosition() > j) { comp.moveCaretPosition(i); comp.scrollRectToVisible(comp.modelToView(i)); } } } catch (BadLocationException ble) { errMgr.internalError(tmodel.root.event.scope.st, "bad highlight location", ble); } }
protected void highlight(JTextComponent comp, int i, int j, boolean scroll) { Highlighter highlighter = comp.getHighlighter(); highlighter.removeAllHighlights(); try { i = toComponentPosition(comp, i); j = toComponentPosition(comp, j); highlighter.addHighlight(i, j+1, DefaultHighlighter.DefaultPainter); if (scroll) { if (comp.getCaretPosition() < i || comp.getCaretPosition() > j) { comp.moveCaretPosition(i); comp.scrollRectToVisible(comp.modelToView(i)); } } } catch (BadLocationException ble) { errMgr.internalError(tmodel.root.event.scope.st, "bad highlight location", ble); } }
protected void highlight(JTextComponent comp, int i, int j, boolean scroll) { Highlighter highlighter = comp.getHighlighter(); highlighter.removeAllHighlights(); try { i = toComponentPosition(comp, i); j = toComponentPosition(comp, j); highlighter.addHighlight(i, j+1, DefaultHighlighter.DefaultPainter); if (scroll) { if (comp.getCaretPosition() < i || comp.getCaretPosition() > j) { comp.moveCaretPosition(i); comp.scrollRectToVisible(comp.modelToView(i)); } } } catch (BadLocationException ble) { errMgr.internalError(tmodel.root.event.scope.st, "bad highlight location", ble); } }
protected void highlight(JTextComponent comp, int i, int j, boolean scroll) { Highlighter highlighter = comp.getHighlighter(); highlighter.removeAllHighlights(); try { i = toComponentPosition(comp, i); j = toComponentPosition(comp, j); highlighter.addHighlight(i, j+1, DefaultHighlighter.DefaultPainter); if (scroll) { if (comp.getCaretPosition() < i || comp.getCaretPosition() > j) { comp.moveCaretPosition(i); comp.scrollRectToVisible(comp.modelToView(i)); } } } catch (BadLocationException ble) { errMgr.internalError(tmodel.root.event.scope.st, "bad highlight location", ble); } }
protected void showValueCompletionPopup( IValuePopup popup, boolean bFocusInEditor ) { getGosuEditor().setValuePopup( popup ); IParseTree currentLocation = getDeepestLocationToComplete(); if( currentLocation != null && currentLocation.getParsedElement() instanceof IExpression && shouldPositionAtStartOfElement( currentLocation, getEditor() ) ) { // Highlight/select the location to be visually specific about what is being acted on. getEditor().setCaretPosition( currentLocation.getOffset() ); getEditor().moveCaretPosition( currentLocation.getOffset() + currentLocation.getLength() ); } getGosuEditor().displayValuePopup( getEditor().getSelectionStart(), bFocusInEditor ); }