当前位置: 首页>>代码示例>>Java>>正文


Java DocumentEvent类代码示例

本文整理汇总了Java中javax.swing.event.DocumentEvent的典型用法代码示例。如果您正苦于以下问题:Java DocumentEvent类的具体用法?Java DocumentEvent怎么用?Java DocumentEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DocumentEvent类属于javax.swing.event包,在下文中一共展示了DocumentEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: insertUpdate

import javax.swing.event.DocumentEvent; //导入依赖的package包/类
/**
 * This method implements the <code>DocumentListener</code>.
 * <br>
 * It is not intended to be called by clients.
 */
public void insertUpdate(DocumentEvent evt) {
    // Check whether there was an insert done right
    // at the original ending offset of the fold
    // so the fold end offset should be moved back.
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("insertUpdate: offset=" + evt.getOffset() // NOI18N
            + ", length=" + evt.getLength() + '\n'); // NOI18N
    }
    try {
        if (FoldHierarchyExecution.isEventInUndoRedoHack(evt)) {
            validateAffectedFolds(execution.getRootFold(), evt);
        }
        
        insertCheckEndOffset(execution.getRootFold(), evt);

    } catch (BadLocationException e) {
        ErrorManager.getDefault().notify(e);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:FoldHierarchyTransactionImpl.java

示例2: updateTexts

import javax.swing.event.DocumentEvent; //导入依赖的package包/类
/** Handles changes in the Project name and project directory
 */
private void updateTexts(DocumentEvent e) {
    Document doc = e.getDocument();
    if (doc.equals(projectNameTextField.getDocument()) || doc.equals(projectLocationTextField.getDocument())) {
        // Change in the project name
        String projectName = projectNameTextField.getText();
        String projectFolder = projectLocationTextField.getText();
        String projFolderPath = FileUtil.normalizeFile(new File(projectFolder)).getAbsolutePath();
        if (projFolderPath.endsWith(File.separator)) {
            createdFolderTextField.setText(projFolderPath + projectName);
        } else {
            createdFolderTextField.setText(projFolderPath + File.separator + projectName);
        }
    }
    
    panel.fireChangeEvent(); // Notify that the panel changed        
    
    if (this.projectNameTextField.getDocument().equals(e.getDocument())) {
        firePropertyChange(PROP_PROJECT_NAME, null, this.projectNameTextField.getText());
    }
    if (this.projectLocationTextField.getDocument().equals(e.getDocument())) {
        firePropertyChange(PROP_PROJECT_LOCATION, null, this.projectLocationTextField.getText());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:PanelProjectLocationVisual.java

示例3: BasicBrandingPanel

import javax.swing.event.DocumentEvent; //导入依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:BasicBrandingPanel.java

示例4: updateDefaultDirectory

import javax.swing.event.DocumentEvent; //导入依赖的package包/类
private void updateDefaultDirectory(DocumentEvent e) {
    Document doc = e.getDocument();
    if (doc.equals(username.getDocument())) {
        String usernameText = username.getText();
        if (!usernameText.isEmpty()) {
            String workdirText = workingDir.getText();
            if (workdirText.isEmpty() || (currentDefaultWorkDir != null && workdirText.equals(currentDefaultWorkDir))) {
                String updatedDefaultworkDir = "/home/" + usernameText + "/NetBeansProjects/"; //NOI18N
                workingDir.setText(updatedDefaultworkDir);
                currentDefaultWorkDir = updatedDefaultworkDir;
            }
        } else {
            if (currentDefaultWorkDir != null && workingDir.getText().equals(currentDefaultWorkDir)) {
                workingDir.setText(""); //NOI18N
                currentDefaultWorkDir = null;
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:SetUpRemotePlatform.java

示例5: createTextFieldLengthDocumentListener

import javax.swing.event.DocumentEvent; //导入依赖的package包/类
/**
 * Listener updates label indicating remaining symbols number like in twitter.
 */
private static DocumentListener createTextFieldLengthDocumentListener(@NotNull TwitterDialogWrapper builder, @NotNull final StudyTwitterUtils.TwitterDialogPanel panel) {
  return new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      int length = e.getDocument().getLength();
      if (length > 140 || length == 0) {
        builder.setOKActionEnabled(false);
        panel.getRemainSymbolsLabel().setText("<html><font color='red'>" + String.valueOf(140 - length) + "</font></html>");
      } else {
        builder.setOKActionEnabled(true);
        panel.getRemainSymbolsLabel().setText(String.valueOf(140 - length));
      }

    }
  };
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:20,代码来源:StudyTwitterUtils.java

示例6: removeUpdate

import javax.swing.event.DocumentEvent; //导入依赖的package包/类
/** Remove from document notification. */
    public void removeUpdate(DocumentEvent evt) {
        checkLengthyAtomicEdit(evt);
        // No longer trigger syntax update related repaint
//        try {
//            BaseDocumentEvent bevt = (BaseDocumentEvent)evt;
//            EditorUI eui = getEditorUI();
//            int y = getYFromPos(evt.getOffset());
//            int lineHeight = eui.getLineHeight();
//            int syntaxY = getYFromPos(bevt.getSyntaxUpdateOffset());
//            // !!! patch for case when DocMarksOp.eolMark is at the end of document
//            if (bevt.getSyntaxUpdateOffset() == evt.getDocument().getLength()) {
//                syntaxY += lineHeight;
//            }
//            if (getComponent().isShowing()) {
//                eui.repaint(y, Math.max(lineHeight, syntaxY - y));
//            }
//
//        } catch (BadLocationException ex) {
//            Utilities.annotateLoggable(ex);
//        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:BaseTextUI.java

示例7: changeTab

import javax.swing.event.DocumentEvent; //导入依赖的package包/类
/**
 *  ȭ���� ������ �ٲ� Ouput�� ���̰� ��ȯ�Ѵ�.
 */
private void changeTab( DocumentEvent e ) {
	if ( e.getDocument() == outputStd.getOutput().getDocument() ) {
		if ( tabPane.getSelectedComponent() != outputStd )
			tabPane.setSelectedComponent(outputStd);
	} else if ( e.getDocument() == outputErr.getOutput().getDocument() ) {
		if ( tabPane.getSelectedComponent() != outputErr )
			tabPane.setSelectedComponent(outputErr);
	}
}
 
开发者ID:FJplant,项目名称:AntIDE,代码行数:13,代码来源:OutputFrame.java

示例8: removeUpdate

import javax.swing.event.DocumentEvent; //导入依赖的package包/类
/** Gives notification from the document that attributes were removed
* in a location that this view is responsible for.
*
* @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
*/
public @Override void removeUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
    try {
        BaseDocumentEvent bevt = (BaseDocumentEvent)evt;
        EditorUI editorUI = getEditorUI();
        int y = getYFromPos(evt.getOffset());
        int lineHeight = editorUI.getLineHeight();
        if (bevt.getLFCount() > 0) { // one or more lines removed
            int removeHeight = bevt.getLFCount() * lineHeight;
            mainHeight -= removeHeight;
            editorUI.repaint(y);

        } else { // removing on one line
            int syntaxY = getYFromPos(bevt.getSyntaxUpdateOffset());
            // !!! patch for case when DocMarksOp.eolMark is at the end of document
            if (bevt.getSyntaxUpdateOffset() == evt.getDocument().getLength()) {
                syntaxY += lineHeight;
            }

            if (getComponent().isShowing()) {
                editorUI.repaint(y, Math.max(lineHeight, syntaxY - y));
            }
        }

    } catch (BadLocationException ex) {
        Utilities.annotateLoggable(ex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:LeafView.java

示例9: changedUpdate

import javax.swing.event.DocumentEvent; //导入依赖的package包/类
public void changedUpdate( DocumentEvent e ) {
    updateTexts( e );
    if (this.projectNameTextField.getDocument() == e.getDocument()) {
        firePropertyChange (PROP_PROJECT_NAME,null,this.projectNameTextField.getText());
    }
    if (this.projectLocationTextField.getDocument() == e.getDocument()) {
        firePropertyChange (PROP_PROJECT_LOCATION,null,this.projectLocationTextField.getText());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:PanelProjectLocationVisual.java

示例10: insertUpdate

import javax.swing.event.DocumentEvent; //导入依赖的package包/类
@Override
public void insertUpdate(DocumentEvent e) {
	try {
		Vector<String> vectorOfStrings = new Vector<String>();
		for (int i = 0; i < getModel().getSize(); i++) {
			vectorOfStrings.add(String.valueOf(getModel().getElementAt(i)));
		}
		Document document = e.getDocument();
		String documentText = document.getText(0, document.getLength());
		final String result = checkForMatch(documentText, vectorOfStrings, caseSensitive);
		final String newString = (result == null) ? documentText : result;
		final int startSelect = document.getLength();
		final int endSelect = newString.length();
		final JTextField editorComponent = (JTextField) getEditor().getEditorComponent();

		if (startSelect == e.getOffset() + e.getLength()) {
			SwingUtilities.invokeLater(new Runnable() {

				@Override
				public void run() {
					setSelectedItem(newString);
					editorComponent.getDocument().removeDocumentListener(docListener);
					editorComponent.setText(newString);
					editorComponent.getDocument().addDocumentListener(docListener);
					Caret caret = editorComponent.getCaret();
					caret.setDot(endSelect);
					caret.moveDot(startSelect);
				}
			});
		}
	} catch (BadLocationException e1) {
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:34,代码来源:AutoCompletionComboBox.java

示例11: insertUpdate

import javax.swing.event.DocumentEvent; //导入依赖的package包/类
@Override
public void insertUpdate(DocumentEvent de) {       
    if(!listen) return; 
    try {
        String added = pane.getStyledDocument().getText(de.getOffset(), de.getLength());
                  
        TextAddedAction action = new TextAddedAction(
                new TextDelta(de.getOffset(), added),
                pane.getStyledDocument());
        actionList.add(action);
    } catch (BadLocationException ex) {
        Logger.getLogger(TextChangedActionAdder.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:Skypr,项目名称:BEAST,代码行数:15,代码来源:TextChangedActionAdder.java

示例12: removeUpdate

import javax.swing.event.DocumentEvent; //导入依赖的package包/类
@Override
public void removeUpdate( DocumentEvent arg0 ) {
    if (this.room != null) {
        this.room.setNotes( this.roomNotes.getText() );
    }

}
 
开发者ID:lauriholmas,项目名称:batmapper,代码行数:8,代码来源:MapperPanel.java

示例13: processInsert

import javax.swing.event.DocumentEvent; //导入依赖的package包/类
private void processInsert(DocumentEvent e) throws BadLocationException {

            final Document document = e.getDocument();
            Element root = document.getDefaultRootElement();
            int start = root.getElementIndex(e.getOffset());
            int end = root.getElementIndex(e.getOffset() + e.getLength() - 1);
            Element startElement = root.getElement(start);
            Element endElement = root.getElement(end);
            if (start == end) {
                String newValue = getText(document, startElement);
                replaceLine(document, start, newValue);
                if (e.getOffset() + e.getLength() == startElement.getEndOffset()) {
                    Element startNext = root.getElement(start + 1);

                    insertLines(document, start + 1, Collections.singletonList(
                            getText(document, startNext)
                    ));
                }
            } else {
                removeLines(document, start, start);

                List<String> lines = new ArrayList<>();

                for (int line = start; line <= end; ++line) {
                    lines.add(getText(document, root.getElement(line)));
                }

               if (e.getOffset() + e.getLength() == endElement.getEndOffset() && end + 1 < root.getElementCount()) {
                    Element endNext = root.getElement(end + 1);
                    lines.add(getText(document, endNext));
                }

                insertLines(document, start, lines);
            }
        }
 
开发者ID:vedun-z,项目名称:difftool,代码行数:36,代码来源:DocumentManager.java

示例14: forwardUpdate

import javax.swing.event.DocumentEvent; //导入依赖的package包/类
protected void forwardUpdate(DocumentEvent.ElementChange ec,
                                 DocumentEvent e, Shape a, ViewFactory f) {
    super.forwardUpdate(ec, e, a, f);
    // A change in any of the table cells usually effects the whole table,
    // so redraw it all!
    if (a != null) {
        Component c = getContainer();
        if (c != null) {
            Rectangle alloc = (a instanceof Rectangle) ? (Rectangle)a :
                               a.getBounds();
            c.repaint(alloc.x, alloc.y, alloc.width, alloc.height);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:TableView.java

示例15: insertUpdate

import javax.swing.event.DocumentEvent; //导入依赖的package包/类
/** Gives notification that something was inserted into the document
* in a location that this view is responsible for.
*
* @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
*/
public @Override void insertUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
    try {
        BaseDocumentEvent bevt = (BaseDocumentEvent)evt;
        EditorUI editorUI = getEditorUI();
        int y = getYFromPos(evt.getOffset());
        int lineHeight = editorUI.getLineHeight();
        if (bevt.getLFCount() > 0) { // one or more lines inserted
            int addHeight = bevt.getLFCount() * lineHeight;
            mainHeight += addHeight;
            editorUI.repaint(y);

        } else { // inserting on one line

            int syntaxY = getYFromPos(bevt.getSyntaxUpdateOffset());
            // !!! patch for case when DocMarksOp.eolMark is at the end of document
            if (bevt.getSyntaxUpdateOffset() == evt.getDocument().getLength()) {
                syntaxY += lineHeight;
            }

            if (getComponent().isShowing()) {
                editorUI.repaint(y, Math.max(lineHeight, syntaxY - y));
            }
        }

    } catch (BadLocationException ex) {
        Utilities.annotateLoggable(ex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:LeafView.java


注:本文中的javax.swing.event.DocumentEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。