javax.swing.event.DocumentEvent Java Examples
The following examples show how to use
javax.swing.event.DocumentEvent.
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: JFontChooser.java From CQL with GNU Affero General Public License v3.0 | 6 votes |
private void update(DocumentEvent event) { String newValue = ""; try { Document doc = event.getDocument(); newValue = doc.getText(0, doc.getLength()); } catch (BadLocationException e) { e.printStackTrace(); } if (newValue.length() > 0) { int index = targetList.getNextMatch(newValue, 0, Position.Bias.Forward); if (index < 0) { index = 0; } targetList.ensureIndexIsVisible(index); String matchedName = targetList.getModel().getElementAt(index).toString(); if (newValue.equalsIgnoreCase(matchedName)) { if (index != targetList.getSelectedIndex()) { SwingUtilities.invokeLater(new ListSelector(index)); } } } }
Example #2
Source File: SingleIntegerFieldOptionsPanel.java From consulo with Apache License 2.0 | 6 votes |
/** * Sets integer number format to JFormattedTextField instance, * sets value of JFormattedTextField instance to object's field value, * synchronizes object's field value with the value of JFormattedTextField instance. * * @param textField JFormattedTextField instance * @param owner an object whose field is synchronized with {@code textField} * @param property object's field name for synchronization */ public static void setupIntegerFieldTrackingValue(final JFormattedTextField textField, final InspectionProfileEntry owner, final String property) { NumberFormat formatter = NumberFormat.getIntegerInstance(); formatter.setParseIntegerOnly(true); textField.setFormatterFactory(new DefaultFormatterFactory(new NumberFormatter(formatter))); textField.setValue(getPropertyValue(owner, property)); final Document document = textField.getDocument(); document.addDocumentListener(new DocumentAdapter() { @Override public void textChanged(DocumentEvent e) { try { textField.commitEdit(); setPropertyValue(owner, property, ((Number) textField.getValue()).intValue()); } catch (ParseException e1) { // No luck this time } } }); }
Example #3
Source File: BasicBrandingPanel.java From netbeans with Apache License 2.0 | 6 votes |
public BasicBrandingPanel(BrandingModel model) { super(NbBundle.getMessage(BasicBrandingPanel.class, "LBL_BasicTab"), model); //NOI18N initComponents(); refresh(); checkValidity(); DocumentListener textFieldChangeListener = new UIUtil.DocumentAdapter() { @Override public void insertUpdate(DocumentEvent e) { checkValidity(); setModified(); titleValueModified = true; } }; titleValue.getDocument().addDocumentListener(textFieldChangeListener); titleValueModified = false; }
Example #4
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
@Override public void insertUpdate(DocumentEvent e) { Document doc = e.getDocument(); Element root = doc.getDefaultRootElement(); if (root.getElementCount() <= MAX_LINES) { return; } EventQueue.invokeLater(() -> removeLines(doc, root)); textComponent.setCaretPosition(doc.getLength()); }
Example #5
Source File: LineNumberBorder.java From nextreports-designer with Apache License 2.0 | 5 votes |
/** * Called whenever a character is input (key is typed) in the text * document we're line-numbering. * * @param event The document event. */ public void insertUpdate(DocumentEvent event) { int newNumLines = editorPane.getDocument().getDefaultRootElement().getElementCount(); if (newNumLines > currentNumLines) { // Adjust the amount of space the line numbers take up, // if necessary. if (newNumLines/10 > currentNumLines / 10) { updateCellWidths(); } currentNumLines = newNumLines; } }
Example #6
Source File: LockView.java From netbeans with Apache License 2.0 | 5 votes |
public void removeUpdate(DocumentEvent e, Shape a, ViewFactory f) { lock(); try { if (view != null) { view.removeUpdate(e, a, f); } } finally { unlock(); } }
Example #7
Source File: XTextAreaPeer.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override public void changedUpdate(DocumentEvent e) { if (peer != null) { peer.postEvent(new TextEvent(peer.target, TextEvent.TEXT_VALUE_CHANGED)); } }
Example #8
Source File: ConnectionType.java From netbeans with Apache License 2.0 | 5 votes |
private void textChanged(final DocumentEvent e) { // repost later to AWT otherwise it can deadlock because // the document is locked while firing event and we try // synchronously access its content from selected repository Runnable awt = new Runnable() { public void run() { textChanged(e.getDocument()); repository.validateSvnUrl(); } }; SwingUtilities.invokeLater(awt); }
Example #9
Source File: FixShebangInspection.java From BashSupport with Apache License 2.0 | 5 votes |
private void updateShebangLines(DocumentEvent documentEvent) { validShebangCommands.clear(); try { Document doc = documentEvent.getDocument(); for (String item : doc.getText(0, doc.getLength()).split("\n")) { if (item.trim().length() != 0) { validShebangCommands.add(item); } } } catch (BadLocationException e) { throw new RuntimeException("Could not save shebang inspection settings input", e); } }
Example #10
Source File: BoxView.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Forwards the given <code>DocumentEvent</code> to the child views * that need to be notified of the change to the model. * If a child changed its requirements and the allocation * was valid prior to forwarding the portion of the box * from the starting child to the end of the box will * be repainted. * * @param ec changes to the element this view is responsible * for (may be <code>null</code> if there were no changes) * @param e the change information from the associated document * @param a the current allocation of the view * @param f the factory to use to rebuild if the view has children * @see #insertUpdate * @see #removeUpdate * @see #changedUpdate * @since 1.3 */ protected void forwardUpdate(DocumentEvent.ElementChange ec, DocumentEvent e, Shape a, ViewFactory f) { boolean wasValid = isLayoutValid(majorAxis); super.forwardUpdate(ec, e, a, f); // determine if a repaint is needed if (wasValid && (! isLayoutValid(majorAxis))) { // Repaint is needed because one of the tiled children // have changed their span along the major axis. If there // is a hosting component and an allocated shape we repaint. Component c = getContainer(); if ((a != null) && (c != null)) { int pos = e.getOffset(); int index = getViewIndexAtPosition(pos); Rectangle alloc = getInsideAllocation(a); if (majorAxis == X_AXIS) { alloc.x += majorOffsets[index]; alloc.width -= majorOffsets[index]; } else { alloc.y += minorOffsets[index]; alloc.height -= minorOffsets[index]; } c.repaint(alloc.x, alloc.y, alloc.width, alloc.height); } } }
Example #11
Source File: ElementTreePanel.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Updates the tree based on the event type. This will invoke either * updateTree with the root element, or handleChange. */ protected void updateTree(DocumentEvent event) { updatingSelection = true; try { TreeModel model = getTreeModel(); Object root = model.getRoot(); for (int counter = model.getChildCount(root) - 1; counter >= 0; counter--) { updateTree(event, (Element) model.getChild(root, counter)); } } finally { updatingSelection = false; } }
Example #12
Source File: ElementTreePanel.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Updates the tree based on the event type. This will invoke either * updateTree with the root element, or handleChange. */ protected void updateTree(DocumentEvent event) { updatingSelection = true; try { TreeModel model = getTreeModel(); Object root = model.getRoot(); for (int counter = model.getChildCount(root) - 1; counter >= 0; counter--) { updateTree(event, (Element) model.getChild(root, counter)); } } finally { updatingSelection = false; } }
Example #13
Source File: InitializrProjectPanelVisual3.java From nb-springboot with Apache License 2.0 | 5 votes |
@Override public void removeUpdate(DocumentEvent e) { updateTexts(e); if (this.projectNameTextField.getDocument() == e.getDocument()) { firePropertyChange(PROP_PROJECT_NAME, null, this.projectNameTextField.getText()); } }
Example #14
Source File: ElementTreePanel.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Updates the tree based on the event type. This will invoke either * updateTree with the root element, or handleChange. */ protected void updateTree(DocumentEvent event) { updatingSelection = true; try { TreeModel model = getTreeModel(); Object root = model.getRoot(); for (int counter = model.getChildCount(root) - 1; counter >= 0; counter--) { updateTree(event, (Element) model.getChild(root, counter)); } } finally { updatingSelection = false; } }
Example #15
Source File: SyntaxDocument.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
/** * We overwrite this method to update the token marker state immediately so that any event * listeners get a consistent token marker. */ @Override protected void fireInsertUpdate(DocumentEvent evt) { if (tokenMarker != null) { DocumentEvent.ElementChange ch = evt.getChange(getDefaultRootElement()); if (ch != null) { tokenMarker.insertLines(ch.getIndex() + 1, ch.getChildrenAdded().length - ch.getChildrenRemoved().length); } } super.fireInsertUpdate(evt); }
Example #16
Source File: Listeners.java From Hollow-Knight-SaveManager with GNU General Public License v3.0 | 5 votes |
@Override public void insertUpdate(DocumentEvent arg0) { check(); if(autoCalc.isSelected()){ SwingUtilities.invokeLater(runAutoCalc); } }
Example #17
Source File: ImportBundleFileDialog.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
protected void handleChange( final DocumentEvent e ) { final String s = entryNameField.getText(); if ( StringUtils.isEmpty( s ) ) { getConfirmAction().setEnabled( false ); return; } if ( StringUtils.isEmpty( (String) mimeTypeBox.getSelectedItem() ) ) { getConfirmAction().setEnabled( false ); return; } getConfirmAction().setEnabled( bundle.isEntryExists( s ) == false ); }
Example #18
Source File: SwingStrategiesUI.java From atdl4j with MIT License | 4 votes |
@Override public void insertUpdate(DocumentEvent e) { fireWidgetChangedEvent(paramName); }
Example #19
Source File: CustomizerProtractor.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void removeUpdate(DocumentEvent e) { processChange(); }
Example #20
Source File: TfDocumentListener.java From uima-uimaj with Apache License 2.0 | 4 votes |
@Override public void changedUpdate(DocumentEvent e) { }
Example #21
Source File: TableDemo.java From beautyeye with Apache License 2.0 | 4 votes |
public void insertUpdate(DocumentEvent e) { changeFilter(e); }
Example #22
Source File: LexerTestUtilities.java From netbeans with Apache License 2.0 | 4 votes |
public static DocumentEvent getLastDocumentEvent(Document doc) { return (DocumentEvent)doc.getProperty(DocumentEvent.class); }
Example #23
Source File: InputValidationDocumentListener.java From PathFinder with Apache License 2.0 | 4 votes |
@Override public void changedUpdate(DocumentEvent e) { onChange(e); }
Example #24
Source File: PlainDocumentCompatibilityRandomTest.java From netbeans with Apache License 2.0 | 4 votes |
public void changedUpdate(DocumentEvent e) { }
Example #25
Source File: DelayedDocumentListener.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
public DelayedDocumentListener(Consumer<DocumentEvent> consumer) { super(); this.consumer = consumer; }
Example #26
Source File: LineTranslations.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void removeUpdate(DocumentEvent e) { lineMightChange(); }
Example #27
Source File: ClassPathFileChooser.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void removeUpdate(DocumentEvent e) { checkNameField(); }
Example #28
Source File: PHPSamplesPanelVisual.java From netbeans with Apache License 2.0 | 4 votes |
public void changedUpdate(DocumentEvent e) { updateTexts(e); if (this.projectNameTextField.getDocument() == e.getDocument()) { firePropertyChange(PROP_PROJECT_NAME, null, this.projectNameTextField.getText()); } }
Example #29
Source File: GeneralCustomizerPanel.java From netbeans with Apache License 2.0 | 4 votes |
public void changedUpdate(DocumentEvent e) { updateTexts(e); }
Example #30
Source File: CompoundUndoManager.java From jeveassets with GNU General Public License v2.0 | 4 votes |
@Override public void changedUpdate(DocumentEvent e) { }