javax.swing.event.CaretListener Java Examples
The following examples show how to use
javax.swing.event.CaretListener.
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: SlotConstTraitDetailPanel.java From jpexs-decompiler with GNU General Public License v3.0 | 6 votes |
public SlotConstTraitDetailPanel(final DecompiledEditorPane editor) { slotConstEditor = new LineMarkedEditorPane(); setLayout(new BorderLayout()); add(new JScrollPane(slotConstEditor), BorderLayout.CENTER); slotConstEditor.setFont(Configuration.getSourceFont()); slotConstEditor.changeContentType("text/flasm3"); slotConstEditor.addCaretListener(new CaretListener() { @Override public void caretUpdate(CaretEvent e) { if (ignoreCaret) { return; } Highlighting spec = Highlighting.searchPos(specialHilights, slotConstEditor.getCaretPosition()); if (spec != null) { editor.hilightSpecial(spec.getProperties().subtype, (int) spec.getProperties().index); slotConstEditor.getCaret().setVisible(true); } } }); }
Example #2
Source File: RowColumnLabel.java From bigtable-sql with Apache License 2.0 | 6 votes |
RowColumnLabel(ISQLEntryPanel sqlEntryPanel) { super(" ", JLabel.CENTER); _sqlEntryPanel = sqlEntryPanel; sqlEntryPanel.addCaretListener(new CaretListener() { public void caretUpdate(CaretEvent e) { onCaretUpdate(e); } }); writePosition(0,0, 0); setToolTipText(s_stringMgr.getString("RowColumnLabel.tooltip")); }
Example #3
Source File: WikiEditPanel.java From netbeans with Apache License 2.0 | 6 votes |
/** * Creates new form WikiEditPanel */ public WikiEditPanel(String wikiLanguage, boolean editing, boolean switchable) { this.wikiLanguage = wikiLanguage; this.switchable = switchable; this.wikiFormatText = ""; this.htmlFormatText = ""; initComponents(); pnlButtons.setVisible(switchable); textCode.getDocument().addDocumentListener(new RevalidatingListener()); textPreview.getDocument().addDocumentListener(new RevalidatingListener()); textCode.addCaretListener(new CaretListener() { @Override public void caretUpdate(CaretEvent e) { makeCaretVisible(textCode); } }); textCode.getDocument().addDocumentListener(new EnablingListener()); // A11Y - Issues 163597 and 163598 UIUtils.fixFocusTraversalKeys(textCode); UIUtils.issue163946Hack(scrollCode); Spellchecker.register(textCode); textPreview.putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); setEditing(editing); }
Example #4
Source File: NavigatorContent.java From netbeans with Apache License 2.0 | 6 votes |
private void updateActiveEditor() { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(this); return; } JTextComponent c = findActivePane(); if (c == null) { editorReleased(); return; } if (activeEditor != null && activeEditor.get() == c) { return; } editorReleased(); activeEditor = new WeakReference<>(c); wCaretL = WeakListeners.create(CaretListener.class, this, c); c.addCaretListener(this); selectCurrentNode(); }
Example #5
Source File: TableViewLayoutTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public TableViewLayoutTest() { super("Code example for a TableView bug"); setUndecorated(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); edit.setEditorKit(new CodeBugEditorKit()); initCodeBug(); this.getContentPane().add(new JScrollPane(edit)); this.pack(); this.setLocationRelativeTo(null); edit.addCaretListener(new CaretListener() { public void caretUpdate(CaretEvent e) { JTextComponent textComp = (JTextComponent) e.getSource(); try { Rectangle rect = textComp.getUI().modelToView(textComp, e.getDot()); yCaret = rect.getY(); xCaret = rect.getX(); } catch (BadLocationException ex) { throw new RuntimeException("Failed to get pixel position of caret", ex); } } }); }
Example #6
Source File: Comment.java From FancyBing with GNU General Public License v3.0 | 5 votes |
public Comment(Listener listener) { m_listener = listener; m_textPane = new JTextPane(); setFocusTraversalKeys(m_textPane); GuiUtil.addStyle(m_textPane, "marked", Color.white, Color.decode("#38d878"), false); setPreferredSize(); m_textPane.getDocument().addDocumentListener(this); CaretListener caretListener = new CaretListener() { public void caretUpdate(CaretEvent event) { if (m_listener == null) return; m_listener.textSelected(m_textPane.getSelectedText()); } }; m_textPane.addCaretListener(caretListener); setViewportView(m_textPane); setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); if (Platform.isMac()) m_normalFont = new Font("Lucida Grande", Font.PLAIN, 11); else m_normalFont = UIManager.getFont("TextPane.font"); setMonoFont(false); }
Example #7
Source File: Amf3ValueEditor.java From jpexs-decompiler with GNU General Public License v3.0 | 5 votes |
@Override public void validateValue() { Amf3Importer importer = new Amf3Importer(); String textVal = editor.getText(); try { if (!textVal.trim().isEmpty()) { importer.stringToAmf(textVal); } } catch (IOException | Amf3ParseException ex) { if (ex instanceof Amf3ParseException) { Amf3ParseException ape = (Amf3ParseException) ex; if (ape.line > 0) { editor.gotoLine((int) ape.line); } } final CaretListener cl = new CaretListener() { @Override public void caretUpdate(CaretEvent e) { errorLabel.setVisible(false); editor.removeCaretListener(this); } }; editor.addCaretListener(cl); errorLabel.setText("<html>" + AppStrings.translate("error") + ":" + ex.getMessage() + "</html>"); errorLabel.setVisible(true); throw new IllegalArgumentException("Invalid AMF value", ex); } }
Example #8
Source File: ConsoleTextEditor.java From groovy with Apache License 2.0 | 5 votes |
private void disableMatchingHighlighter() { for (CaretListener cl : textEditor.getCaretListeners()) { if (cl instanceof MatchingHighlighter) { textEditor.removeCaretListener(cl); } } }
Example #9
Source File: JEditTextArea.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
protected void fireCaretEvent() { Object[] listeners = listenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i--) { if (listeners[i] == CaretListener.class) { ((CaretListener) listeners[i + 1]).caretUpdate(caretEvent); } } }
Example #10
Source File: IPV4Field.java From lippen-network-tool with Apache License 2.0 | 5 votes |
@Override public void removeCaretListener(CaretListener listener) { if (this.ipFields != null) { for (JIPV4Field field : this.ipFields) { field.removeCaretListener(listener); } } }
Example #11
Source File: IPV4Field.java From lippen-network-tool with Apache License 2.0 | 5 votes |
@Override public void addCaretListener(CaretListener listener) { if (this.ipFields != null) { for (JIPV4Field field : this.ipFields) { field.addCaretListener(listener); } } }
Example #12
Source File: JTextComponentOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Maps {@code JTextComponent.removeCaretListener(CaretListener)} * through queue */ public void removeCaretListener(final CaretListener caretListener) { runMapping(new MapVoidAction("removeCaretListener") { @Override public void map() { ((JTextComponent) getSource()).removeCaretListener(caretListener); } }); }
Example #13
Source File: JTextComponentOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Maps {@code JTextComponent.addCaretListener(CaretListener)} through queue */ public void addCaretListener(final CaretListener caretListener) { runMapping(new MapVoidAction("addCaretListener") { @Override public void map() { ((JTextComponent) getSource()).addCaretListener(caretListener); } }); }
Example #14
Source File: TaskPanel.java From netbeans with Apache License 2.0 | 5 votes |
/** * Creates new form TaskPanel */ public TaskPanel (LocalTask task) { this.task = task; initComponents(); updateReadOnlyField(headerField); Font font = new JLabel().getFont(); headerField.setFont(font.deriveFont((float) (font.getSize() * 1.7))); mainScrollPane.getVerticalScrollBar().setUnitIncrement(10); privateNotesField.addCaretListener(new CaretListener() { @Override public void caretUpdate (CaretEvent e) { makeCaretVisible(privateNotesField); } }); // A11Y - Issues 163597 and 163598 UIUtils.fixFocusTraversalKeys(privateNotesField); initSpellChecker(); attachmentsPanel = new AttachmentsPanel(this); attachmentsSection.setContent(attachmentsPanel); GroupLayout layout = (GroupLayout) attributesPanel.getLayout(); dueDatePicker = UIUtils.createDatePickerComponent(); scheduleDatePicker = new SchedulePicker(); layout.replace(dummyDueDateField, dueDatePicker.getComponent()); dueDateLabel.setLabelFor(dueDatePicker.getComponent()); layout.replace(dummyScheduleDateField, scheduleDatePicker.getComponent()); scheduleDateLabel.setLabelFor(scheduleDatePicker.getComponent()); attachListeners(); }
Example #15
Source File: SearchBar.java From netbeans with Apache License 2.0 | 5 votes |
private CaretListener createCaretListenerForComponent() { return new CaretListener() { @Override public void caretUpdate(CaretEvent e) { if (SearchBar.getInstance().isVisible()) { int num = SearchBar.getInstance().getNumOfMatches(); SearchBar.getInstance().showNumberOfMatches(null, num); } } }; }
Example #16
Source File: EditMenuControls.java From pumpernickel with MIT License | 4 votes |
private void registerAction(EditCommand<AbstractAction> command, final Selection selection, final boolean requiresEdits) { final AbstractAction action = new EditMenuAction( (String) command.getValue(AbstractAction.ACTION_COMMAND_KEY)); PropertyChangeListener pcl = new PropertyChangeListener() { JTextComponent textComponent; CaretListener caretListener = new CaretListener() { @Override public void caretUpdate(CaretEvent e) { refresh(); } }; @Override public void propertyChange(PropertyChangeEvent evt) { Component c = KeyboardFocusManager .getCurrentKeyboardFocusManager().getFocusOwner(); if (c == textComponent) return; JTextComponent jtc = c instanceof JTextComponent ? ((JTextComponent) c) : null; if (textComponent != null) textComponent.removeCaretListener(caretListener); textComponent = jtc; if (textComponent != null) textComponent.addCaretListener(caretListener); refresh(); } private void refresh() { if (textComponent == null) { action.setEnabled(false); } else if (!textComponent.isEditable() && requiresEdits) { action.setEnabled(false); } else if (selection == null) { action.setEnabled(true); } else { action.setEnabled(selection.accepts(textComponent)); } } }; KeyboardFocusManager.getCurrentKeyboardFocusManager() .addPropertyChangeListener("focusOwner", pcl); command.install(action); registerAction(action); }
Example #17
Source File: DefaultSQLEntryPanel.java From bigtable-sql with Apache License 2.0 | 4 votes |
public void addCaretListener(CaretListener lis) { _comp.addCaretListener(lis); }
Example #18
Source File: DefaultSQLEntryPanel.java From bigtable-sql with Apache License 2.0 | 4 votes |
public void removeCaretListener(CaretListener lis) { _comp.removeCaretListener(lis); }
Example #19
Source File: GtpShell.java From FancyBing with GNU General Public License v3.0 | 4 votes |
public GtpShell(Frame owner, Listener listener, MessageDialogs messageDialogs) { super(owner, i18n("TIT_SHELL")); m_messageDialogs = messageDialogs; m_listener = listener; Preferences prefs = Preferences.userNodeForPackage(getClass()); m_historyMin = prefs.getInt("history-min", 2000); m_historyMax = prefs.getInt("history-max", 3000); JPanel panel = new JPanel(new BorderLayout()); getContentPane().add(panel, BorderLayout.CENTER); m_gtpShellText = new GtpShellText(m_historyMin, m_historyMax, false); CaretListener caretListener = new CaretListener() { public void caretUpdate(CaretEvent event) { if (m_listener == null) return; // Call the callback only if the selected text has changed. // This avoids that the callback is called multiple times // if the caret position changes, but the text selection // was null before and after the change (see also bug // #2964755) String selectedText = m_gtpShellText.getSelectedText(); if (! ObjectUtil.equals(selectedText, m_selectedText)) { m_listener.textSelected(selectedText); m_selectedText = selectedText; } } }; m_gtpShellText.addCaretListener(caretListener); m_scrollPane = new JScrollPane(m_gtpShellText, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); if (Platform.isMac()) // Default Apple L&F uses no border, but Quaqua 3.7.4 does m_scrollPane.setBorder(null); panel.add(m_scrollPane, BorderLayout.CENTER); panel.add(createCommandInput(), BorderLayout.SOUTH); setMinimumSize(new Dimension(160, 112)); pack(); }
Example #20
Source File: JEditTextArea.java From rapidminer-studio with GNU Affero General Public License v3.0 | 2 votes |
/** * Adds a caret change listener to this text area. * * @param listener * The listener */ public final void addCaretListener(CaretListener listener) { listenerList.add(CaretListener.class, listener); }
Example #21
Source File: JEditTextArea.java From rapidminer-studio with GNU Affero General Public License v3.0 | 2 votes |
/** * Removes a caret change listener from this text area. * * @param listener * The listener */ public final void removeCaretListener(CaretListener listener) { listenerList.remove(CaretListener.class, listener); }
Example #22
Source File: ISQLEntryPanel.java From bigtable-sql with Apache License 2.0 | votes |
void addCaretListener(CaretListener lis);
Example #23
Source File: ISQLEntryPanel.java From bigtable-sql with Apache License 2.0 | votes |
void removeCaretListener(CaretListener lis);