javax.swing.event.TreeSelectionListener#javax.swing.event.DocumentEvent源码实例Demo

下面列出了javax.swing.event.TreeSelectionListener#javax.swing.event.DocumentEvent 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: CQL   文件: JFontChooser.java
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));
			}
		}
	}
}
 
源代码2 项目: netbeans   文件: BasicBrandingPanel.java
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;
}
 
源代码3 项目: consulo   文件: SingleIntegerFieldOptionsPanel.java
/**
 * 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
            }
        }
    });
}
 
源代码4 项目: openjdk-jdk8u-backup   文件: ElementTreePanel.java
/**
 * 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;
    }
}
 
源代码5 项目: nextreports-designer   文件: LineNumberBorder.java
/**
 * 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;
	}
}
 
源代码6 项目: jdk8u60   文件: XTextAreaPeer.java
@Override
public void changedUpdate(DocumentEvent e) {
    if (peer != null) {
        peer.postEvent(new TextEvent(peer.target,
                                     TextEvent.TEXT_VALUE_CHANGED));
    }
}
 
源代码7 项目: jdk1.8-source-analysis   文件: BoxView.java
/**
 * 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);
        }
    }
}
 
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 );
}
 
源代码9 项目: rapidminer-studio   文件: SyntaxDocument.java
/**
 * 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);
}
 
源代码10 项目: netbeans   文件: LockView.java
public void removeUpdate(DocumentEvent e, Shape a, ViewFactory f) {
    lock();
    try {
        
        if (view != null) {
            view.removeUpdate(e, a, f);
        }

    } finally {
        unlock();
    }
}
 
@Override
public void removeUpdate(DocumentEvent e) {
    updateTexts(e);
    if (this.projectNameTextField.getDocument() == e.getDocument()) {
        firePropertyChange(PROP_PROJECT_NAME, null, this.projectNameTextField.getText());
    }
}
 
源代码12 项目: BashSupport   文件: FixShebangInspection.java
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);
    }
}
 
源代码13 项目: netbeans   文件: ConnectionType.java
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);
}
 
源代码14 项目: dragonwell8_jdk   文件: ElementTreePanel.java
/**
 * 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;
    }
}
 
源代码15 项目: java-swing-tips   文件: MainPanel.java
@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());
}
 
源代码16 项目: jdk8u-jdk   文件: ElementTreePanel.java
/**
 * 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;
    }
}
 
源代码17 项目: Hollow-Knight-SaveManager   文件: Listeners.java
@Override
public void insertUpdate(DocumentEvent arg0) {
	check();
	if(autoCalc.isSelected()){
		SwingUtilities.invokeLater(runAutoCalc);
	}
}
 
源代码18 项目: pcgen   文件: TextFieldListener.java
@Override
public void changedUpdate(DocumentEvent e)
{
	textChanged(textField.getText());
}
 
源代码19 项目: SVG-Android   文件: VectorContentViewer.java
@Override
public void removeUpdate(DocumentEvent e) {
    if (mTextWatcher != null) {
        mTextWatcher.onChange(mTextArea.getText());
    }
}
 
源代码20 项目: netbeans   文件: TaskPanel.java
@Override
public final void removeUpdate (DocumentEvent e) {
    fieldModified();
}
 
@Override
public void changedUpdate(DocumentEvent e) {
    setOkState();
}
 
源代码22 项目: symja_android_library   文件: IOFunctions.java
@Override
public void insertUpdate(DocumentEvent e) {
	updateFieldState();
}
 
源代码23 项目: darklaf   文件: InsertDocumentListener.java
@Override
default void insertUpdate(final DocumentEvent e) {
    onInsert();
}
 
源代码24 项目: netbeans   文件: Export.java
@Override
public void insertUpdate(DocumentEvent e) {
    validateUserInput();
}
 
源代码25 项目: chipster   文件: SessionDetails.java
public void changedUpdate(DocumentEvent e) {
	fieldUpdated(e);		
}
 
public void changedUpdate(DocumentEvent e) {
    changeSupport.fireChange();
}
 
源代码27 项目: darklaf   文件: UpdateDocumentListener.java
default void removeUpdate(final DocumentEvent e) {
    update();
}
 
源代码28 项目: netbeans   文件: AbstractCheckoutRevision.java
@Override
public void insertUpdate (DocumentEvent e) {
    validateName();
}
 
源代码29 项目: netbeans   文件: WikiEditPanel.java
@Override
public void removeUpdate(DocumentEvent e) {
    changedUpdate(e);
}
 
源代码30 项目: darklaf   文件: DarkFormattedTextFieldUI.java
@Override
public void removeUpdate(final DocumentEvent e) {
    update();
}