public void focusLost(FocusEvent e) { textComponent.select(0, 0); updateSampleFont(); } }
@Override protected Transferable createTransferable(JComponent c) { String text = details.getSelectedText(); if (text == null || text.equals("")) { details.selectAll(); text = details.getSelectedText(); details.select(-1, -1); } return new StringSelection(text); }
protected Transferable createTransferable(JComponent c) { String text = details.getSelectedText(); if (text == null || text.equals("")) { details.selectAll(); text = details.getSelectedText(); details.select(-1, -1); } return new StringSelection(text); }
private void newAutocomplete(KeyEvent e) { final JTextComponent input = (JTextComponent)e.getSource(); final String inputText = input.getText(); final String nameStart = inputText.substring(0, input.getSelectionStart()) + e.getKeyChar(); if (findAutocompleteName(nameStart)) { // Assert this.autocompleteName != null final String name = this.autocompleteName; SwingUtilities.invokeLater(() -> { try { input.getDocument().insertString( nameStart.length(), name.substring(nameStart.length()), null); input.select(nameStart.length(), name.length()); } catch (BadLocationException ex) { log.warn("Could not autocomplete name.", ex); } }); } }
@Override protected Transferable createTransferable(JComponent c) { String text = details.getSelectedText(); if (text == null || text.equals("")) { details.selectAll(); text = details.getSelectedText(); details.select(-1, -1); } return new StringSelection(text); }
pos = findNext(false, pos); if (pos > -1) { textComponent.select(pos, pos + find.length()); } else { textComponent.setCaretPosition(last + replace.length());
@Override protected Transferable createTransferable(JComponent c) { String text = details.getSelectedText(); if (text == null || text.equals("")) { details.selectAll(); text = details.getSelectedText(); details.select(-1, -1); } return new StringSelection(text); }
textComponent.select(pos, pos + find.length()); } else { textComponent.setCaretPosition(last + replace.length());
@Override protected Transferable createTransferable(JComponent c) { String text = details.getSelectedText(); if (text == null || text.equals("")) { details.selectAll(); text = details.getSelectedText(); details.select(-1, -1); } return new StringSelection(text); }
doc.remove(insertIndex, 1); doc.insertString(insertIndex, charToInsert, null); input.select(insertIndex + 1, input.getSelectionEnd());
public void actionPerformed(ActionEvent ae) { lastAction = FIND_ACTION_COMMAND; findReplaceCount = 0; if (FIND_REPLACE_DIALOG.isVisible() && FIND_REPLACE_DIALOG.getTitle().equals(FIND_ACTION_COMMAND)) { } int pos = textComponent.getSelectedText() == null ? textComponent.getCaretPosition() : textComponent.getSelectionStart(); boolean reverse = (ae.getModifiers() & ActionEvent.SHIFT_MASK) != 0; pos = findNext(reverse, pos); if (pos > -1) { String pattern = (String) FIND_FIELD.getSelectedItem(); textComponent.select(pos, pos + pattern.length()); findReplaceCount = 1; } setListStrings(); fireTextEvent(); } }
@Override public void focusLost(FocusEvent e) { textComponent.select(0, 0); updateSampleFont(); } }
static void clearTextFieldSelectionAsync(final JTextComponent textField) { SwingUtilities.invokeLater(() -> { textField.select(0, 0); final int length = textField.getDocument().getLength(); try { textField.setCaretPosition(length); } catch (Exception ignore) { System.err.println("Can't set caret position to length: " + length); } }); } }
@Override public void focusLost(FocusEvent e) { this.textComponent.select(0, 0); updateSampleFont(); } }
/** * Deselects the text when a field loses the focus. * * @param e the event. */ public void focusLost(final FocusEvent e) { if (e.getSource() instanceof JTextComponent) { final JTextComponent tex = (JTextComponent) e.getSource(); tex.select(0, 0); } }
/** * Deselects the text when a field loses the focus. * * @param e the event. */ public void focusLost(final FocusEvent e) { if (e.getSource() instanceof JTextComponent) { final JTextComponent tex = (JTextComponent) e.getSource(); tex.select(0, 0); } }
/** * Deselects the text when a field loses the focus. * * @param e the event. */ public void focusLost(final FocusEvent e) { if (e.getSource() instanceof JTextComponent) { final JTextComponent tex = (JTextComponent) e.getSource(); tex.select(0, 0); } }
private void selectLineForOffset(int y) { int pos = editor.viewToModel(new Point(0, y)); if (pos >= 0) { Element root = editor.getDocument().getDefaultRootElement(); Element elem = root.getElement(root.getElementIndex(pos)); if (elem != null) { int start = elem.getStartOffset(); int end = elem.getEndOffset(); editor.select(start, Math.max(end-1, 0)); } } } }
@Override public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) { Token t = sDoc.getTokenAt(dot); if(t != null) { target.select(t.start, t.end()); } if (dlg == null) { dlg = new ReflectCompletionDialog(target); } dlg.displayFor(target); } }
@Override public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) { Token t = sDoc.getTokenAt(dot); if(t != null) { target.select(t.start, t.end()); } if (dlg == null) { dlg = new ReflectCompletionDialog(target); } dlg.displayFor(target); } }