javax.swing.event.DocumentEvent#getDocument()源码实例Demo

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

源代码1 项目: gcs   文件: BaseSpellEditor.java
/** Always call the super implementation when overriding this method. */
@Override
public void changedUpdate(DocumentEvent event) {
    Document doc = event.getDocument();
    if (doc == mNameField.getDocument()) {
        LinkedLabel.setErrorMessage(mNameField, mNameField.getText().trim().isEmpty() ? I18n.Text("The name field may not be empty") : null);
    } else if (doc == mClassField.getDocument()) {
        LinkedLabel.setErrorMessage(mClassField, mClassField.getText().trim().isEmpty() ? I18n.Text("The class field may not be empty") : null);
    } else if (doc == mCastingCostField.getDocument()) {
        LinkedLabel.setErrorMessage(mCastingCostField, mCastingCostField.getText().trim().isEmpty() ? I18n.Text("The casting cost field may not be empty") : null);
    } else if (doc == mCastingTimeField.getDocument()) {
        LinkedLabel.setErrorMessage(mCastingTimeField, mCastingTimeField.getText().trim().isEmpty() ? I18n.Text("The casting time field may not be empty") : null);
    } else if (doc == mDurationField.getDocument()) {
        LinkedLabel.setErrorMessage(mDurationField, mDurationField.getText().trim().isEmpty() ? I18n.Text("The duration field may not be empty") : null);
    }
}
 
protected void handleChange( final DocumentEvent e ) {
  if ( inUpdate ) {
    return;
  }
  final DataSetQuery<T> item = dialogModel.getQueries().getSelectedQuery();
  if ( item == null ) {
    return;
  }

  try {
    inUpdate = true;
    final Document document = e.getDocument();
    final String queryName = document.getText( 0, document.getLength() );
    item.setQueryName( queryName );
    dialogModel.getQueries().fireItemChanged( item );
  } catch ( BadLocationException e1 ) {
    e1.printStackTrace();
  } finally {
    inUpdate = false;
  }

}
 
源代码3 项目: netbeans   文件: PanelProjectLocationVisual.java
/** Handles changes in the Project name and project directory
 */
private void updateTexts( DocumentEvent e ) {
    Document doc = e.getDocument();
    if ( doc == projectNameTextField.getDocument() || doc == 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        
}
 
源代码4 项目: netbeans   文件: BaseTextUI.java
private void checkLengthyAtomicEdit(DocumentEvent evt) {
        if (atomicModCount != -1) {
            if (++atomicModCount == LENGTHY_ATOMIC_EDIT_THRESHOLD) {
                Document doc = evt.getDocument();
                // Deactivate view hierarchy
                View rootView = getRootView(getComponent());
                View view;
                if (rootView != null && rootView.getViewCount() > 0 &&
                        (view = rootView.getView(0)) instanceof org.netbeans.modules.editor.lib2.view.DocumentView)
                {
                    ((org.netbeans.modules.editor.lib2.view.DocumentView)view).updateLengthyAtomicEdit(+1);
                }
                // Inactivate lexer's token hierarchy
                // Commented out due to #200270
//                MutableTextInput input = (MutableTextInput) doc.getProperty(MutableTextInput.class);
//                if (input != null) {
//                    input.tokenHierarchyControl().setActive(false);
//                }
            }
        }
    }
 
源代码5 项目: gcs   文件: DisplayPreferences.java
@Override
public void changedUpdate(DocumentEvent event) {
    Preferences prefs    = Preferences.getInstance();
    Document    document = event.getDocument();
    if (mBlockLayoutField.getDocument() == document) {
        prefs.setBlockLayout(List.of(mBlockLayoutField.getText().split("\n")));
    } else if (mToolTipTimeout.getDocument() == document) {
        prefs.setToolTipTimeout(Numbers.extractInteger(mToolTipTimeout.getText(), Preferences.DEFAULT_TOOLTIP_TIMEOUT, Preferences.MINIMUM_TOOLTIP_TIMEOUT, Preferences.MAXIMUM_TOOLTIP_TIMEOUT, true));
    }
    adjustResetButton();
}
 
源代码6 项目: netbeans   文件: AbstractOutputPane.java
public final void insertUpdate(DocumentEvent e) {
    //Ensure it is consumed
    e.getLength();
    documentChanged();
    if (e.getOffset() + e.getLength() >= getCaretPos() && (locked || !(e instanceof OutputDocument.DO))) {
        //#119985 only move caret when not in editable section
        OutputDocument doc = (OutputDocument)e.getDocument();
        if (! (e instanceof OutputDocument.DO) && getCaretPos() >= doc.getOutputLength()) {
            return ;
        }
        
        getCaret().setDot(e.getOffset() + e.getLength());
    }
}
 
源代码7 项目: portable-ftp-server   文件: MessageConsole.java
/**
 * Removes the lines.
 *
 * @param e the e
 */
private void removeLines(DocumentEvent e) {
	Document document = e.getDocument();
	Element root = document.getDefaultRootElement();
	while (root.getElementCount() > maximumLines) {
		Element line = root.getElement(0);
		int end = line.getEndOffset();
		try {
			document.remove(0, end);
		} catch(BadLocationException ble) {
			//System.out.println(ble);
		}
	}
}
 
源代码8 项目: WhiteRabbit   文件: DetailsPanel.java
@Override
public void removeUpdate(DocumentEvent e) {
	if (e.getDocument() == logicArea.getDocument())
		itemToItemMap.setLogic(logicArea.getText());
	else
		itemToItemMap.setComment(commentsArea.getText());
}
 
源代码9 项目: netbeans   文件: BasicProjectInfoPanel.java
private void update(DocumentEvent e) {
    if (ignoreEvent) {
        // side-effect of changes done in this handler
        return;
    }

    // start ignoring events
    ignoreEvent = true;

    if (projectLocation.getDocument() == e.getDocument()) {
        antScriptValidityChecked = false;
        updateAntScriptLocation();
        updateProjectName();
        updateProjectFolder();
    }
    if (antScript.getDocument() == e.getDocument()) {
        antScriptValidityChecked = false;
        updateProjectName();
    }

    // stop ignoring events
    ignoreEvent = false;

    if (projectFolder.getDocument() == e.getDocument()) {
        projectFolderTouched = !"".equals(projectFolder.getText());  //NOI18N
    }
    if (antScript.getDocument() == e.getDocument()) {
        antScriptTouched = !"".equals(antScript.getText());  //NOI18N
    }
    if (projectName.getDocument() == e.getDocument()) {
        projectNameTouched = !"".equals(projectName.getText());  //NOI18N
    }

    listener.stateChanged(null);
}
 
源代码10 项目: 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);
    }
}
 
源代码11 项目: netbeans   文件: Editor.java
private void markChanged( DocumentEvent evt ) {
    Document doc = evt.getDocument();
    doc.putProperty( MODIFIED, Boolean.TRUE );
    
    File file = (File)doc.getProperty( FILE );
    int index = tabPane.indexOfComponent( comp );
    
    tabPane.setTitleAt( index, file.getName() + '*' );
    
    doc.removeDocumentListener( this );
}
 
源代码12 项目: visualvm   文件: subnodesPanelVisual.java
public void removeUpdate(DocumentEvent e) {
    updateTexts(e);
    if (this.projectNameTextField.getDocument() == e.getDocument()) {
        firePropertyChange(PROP_PROJECT_NAME, null, this.projectNameTextField.getText());
    }
}
 
源代码13 项目: netbeans   文件: PHPSamplesPanelVisual.java
/** Handles changes in the Project name and project directory, */
private void updateTexts(DocumentEvent e) {

    Document doc = e.getDocument();

    if (doc == projectNameTextField.getDocument() || doc == projectLocationTextField.getDocument()) {
        // Change in the project name

        String projectName = projectNameTextField.getText();
        String projectFolder = projectLocationTextField.getText();

        //if (projectFolder.trim().length() == 0 || projectFolder.equals(oldName)) {
        createdFolderTextField.setText(projectFolder + File.separatorChar + projectName);
    //}

    }
    panel.fireChangeEvent(); // Notify that the panel changed

}
 
源代码14 项目: netbeans   文件: GroovyJavaDemoPanelVisual.java
public void changedUpdate(DocumentEvent e) {
    updateTexts(e);
    if (this.projectNameTextField.getDocument() == e.getDocument()) {
        firePropertyChange(PROP_PROJECT_NAME, null, this.projectNameTextField.getText());
    }
}
 
源代码15 项目: visualvm   文件: hostviewPanelVisual.java
/** Handles changes in the Project name and project directory, */
private void updateTexts(DocumentEvent e) {

    Document doc = e.getDocument();

    if (doc == projectNameTextField.getDocument() || doc == projectLocationTextField.getDocument()) {
        // Change in the project name

        String projectName = projectNameTextField.getText();
        String projectFolder = projectLocationTextField.getText();

        //if (projectFolder.trim().length() == 0 || projectFolder.equals(oldName)) {
        createdFolderTextField.setText(projectFolder + File.separatorChar + projectName);
    //}

    }
    panel.fireChangeEvent(); // Notify that the panel changed

}
 
源代码16 项目: chipster   文件: SessionDetails.java
private void fieldUpdated(DocumentEvent e) {
	if (e.getDocument() == notesField.getDocument()) {
		setNotesActive(true);
		application.getSessionManager().setSessionNotes(getNotesContent());
	}
}
 
源代码17 项目: netbeans   文件: PHPSamplesPanelVisual.java
public void removeUpdate(DocumentEvent e) {
    updateTexts(e);
    if (this.projectNameTextField.getDocument() == e.getDocument()) {
        firePropertyChange(PROP_PROJECT_NAME, null, this.projectNameTextField.getText());
    }
}
 
源代码18 项目: visualvm   文件: datasourcePanelVisual.java
/** Handles changes in the Project name and project directory, */
private void updateTexts(DocumentEvent e) {

    Document doc = e.getDocument();

    if (doc == projectNameTextField.getDocument() || doc == projectLocationTextField.getDocument()) {
        // Change in the project name

        String projectName = projectNameTextField.getText();
        String projectFolder = projectLocationTextField.getText();

        //if (projectFolder.trim().length() == 0 || projectFolder.equals(oldName)) {
        createdFolderTextField.setText(projectFolder + File.separatorChar + projectName);
    //}

    }
    panel.fireChangeEvent(); // Notify that the panel changed

}
 
public void removeUpdate(DocumentEvent e) {
    updateTexts(e);
    if (this.projectNameTextField.getDocument() == e.getDocument()) {
        firePropertyChange(PROP_PROJECT_NAME, null, this.projectNameTextField.getText());
    }
}
 
源代码20 项目: visualvm   文件: jvmcapsPanelVisual.java
/** Handles changes in the Project name and project directory, */
private void updateTexts(DocumentEvent e) {

    Document doc = e.getDocument();

    if (doc == projectNameTextField.getDocument() || doc == projectLocationTextField.getDocument()) {
        // Change in the project name

        String projectName = projectNameTextField.getText();
        String projectFolder = projectLocationTextField.getText();

        //if (projectFolder.trim().length() == 0 || projectFolder.equals(oldName)) {
        createdFolderTextField.setText(projectFolder + File.separatorChar + projectName);
    //}

    }
    panel.fireChangeEvent(); // Notify that the panel changed

}