类javax.swing.event.DocumentListener源码实例Demo

下面列出了怎么用javax.swing.event.DocumentListener的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: netbeans   文件: OutputDocument.java
public void addDocumentListener(DocumentListener listener) {
    if (listener == null) {
        return;
    }

    if (docListeners == null) {
        docListeners = new DocumentListener[1];
        docListeners[0] = listener;
    } else {
        DocumentListener[] oldArr = docListeners;
        docListeners = new DocumentListener[oldArr.length + 1];
        System.arraycopy(oldArr, 0,
                         docListeners, 0,
                         oldArr.length);
        docListeners[oldArr.length] = listener;
    }
}
 
源代码2 项目: netbeans   文件: SampleVisualPanel.java
private void initProjectNameAndLocation(WizardDescriptor descriptor) {
    // default name & location
    File projectLocation = ProjectChooser.getProjectsFolder();
    projectLocationTextField.setText(projectLocation.getAbsolutePath());

    FileObject template = Templates.getTemplate(descriptor);
    String projectName = template.getName();
    String templateName = projectName;
    int index = 0;
    while ((new File(projectLocation, projectName)).exists()) {
        index++;
        projectName = templateName + index;
    }
    projectNameTextField.setText(projectName);
    projectNameTextField.selectAll();
    updateProjectFolder();

    // listeners
    DocumentListener documentListener = new DefaultDocumentListener();
    projectNameTextField.getDocument().addDocumentListener(documentListener);
    projectLocationTextField.getDocument().addDocumentListener(documentListener);
    setName(NbBundle.getMessage(OnlineSampleVisualPanel.class, "LBL_NameAndLocation"));// NOI18N
    
}
 
源代码3 项目: netbeans   文件: NewClientSideProject.java
private void initProjectNameAndLocation() {
    // default name & location
    File projectLocation = ProjectChooser.getProjectsFolder();
    projectLocationTextField.setText(projectLocation.getAbsolutePath());

    String projectName = projectNameTemplate;
    int index = 0;
    while ((new File(projectLocation, projectName)).exists()) {
        index++;
        projectName = projectNameTemplate + index;
    }
    projectNameTextField.setText(projectName);
    projectNameTextField.selectAll();
    updateProjectFolder();

    // listeners
    DocumentListener documentListener = new DefaultDocumentListener();
    projectNameTextField.getDocument().addDocumentListener(documentListener);
    projectLocationTextField.getDocument().addDocumentListener(documentListener);
}
 
源代码4 项目: netbeans   文件: SampleVisualPanel.java
private void initProjectNameAndLocation(WizardDescriptor descriptor) {
    // default name & location
    File projectLocation = ProjectChooser.getProjectsFolder();
    projectLocationTextField.setText(projectLocation.getAbsolutePath());

    FileObject template = Templates.getTemplate(descriptor);
    String projectName = template.getName();
    String templateName = projectName;
    int index = 0;
    while ((new File(projectLocation, projectName)).exists()) {
        index++;
        projectName = templateName + index;
    }
    projectNameTextField.setText(projectName);
    projectNameTextField.selectAll();
    updateProjectFolder();

    // listeners
    DocumentListener documentListener = new DefaultDocumentListener();
    projectNameTextField.getDocument().addDocumentListener(documentListener);
    projectLocationTextField.getDocument().addDocumentListener(documentListener);
    setName(NbBundle.getMessage(SampleVisualPanel.class, "LBL_NameAndLocation"));// NOI18N
    
}
 
源代码5 项目: 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;
}
 
源代码6 项目: netbeans   文件: NameAndLocationPanel.java
/** Creates new NameAndLocationPanel */
public NameAndLocationPanel(final WizardDescriptor setting, final NewLibraryDescriptor.DataModel data) {
    super(setting);
    this.data = data;
    initComponents();
    initAccessibility();
    putClientProperty("NewFileWizard_Title",// NOI18N
            NbBundle.getMessage(NameAndLocationPanel.class,"LBL_LibraryWizardTitle")); // NOI18N
    
    DocumentListener dListener = new UIUtil.DocumentAdapter() {
        public void insertUpdate(DocumentEvent e) {
            NewLibraryDescriptor.DataModel _data = getTemporaryDataModel();                
            setEnabledForFilesInfo(checkValidity(_data));
            setFilesInfoIntoTextAreas(_data);
        }
    };
    libraryNameVale.getDocument().addDocumentListener(dListener);
    libraryDisplayNameValue.getDocument().addDocumentListener(dListener);        
}
 
源代码7 项目: netbeans   文件: NameAndLocationPanel.java
/** Creates new NameAndLocationPanel */
public NameAndLocationPanel(final WizardDescriptor setting, final HTMLIterator.DataModel data) {
    super(setting);
    this.data = data;
    initComponents();
    initAccessibility();
    putClientProperty("NewFileWizard_Title", getMessage("LBL_TCWizardTitle"));
    
    DocumentListener dListener = new UIUtil.DocumentAdapter() {
        public void insertUpdate(DocumentEvent e) {
            if (checkValidity()) {
                updateData();
            }
        }
    };
    txtPrefix.getDocument().addDocumentListener(dListener);
    txtIcon.getDocument().addDocumentListener(dListener);
    
    if (comPackageName.getEditor().getEditorComponent() instanceof JTextField) {
        JTextField txt = (JTextField)comPackageName.getEditor().getEditorComponent();
        txt.getDocument().addDocumentListener(dListener);
    }
}
 
源代码8 项目: netbeans   文件: NameAndLocationPanel.java
/** Creates new NameAndLocationPanel */
public NameAndLocationPanel(final WizardDescriptor setting, final NewTCIterator.DataModel data) {
    super(setting);
    this.data = data;
    initComponents();
    initAccessibility();
    putClientProperty("NewFileWizard_Title", getMessage("LBL_TCWizardTitle"));
    
    DocumentListener dListener = new UIUtil.DocumentAdapter() {
        public void insertUpdate(DocumentEvent e) {
            if (checkValidity()) {
                updateData();
            }
        }
    };
    txtPrefix.getDocument().addDocumentListener(dListener);
    txtIcon.getDocument().addDocumentListener(dListener);
    
    if (comPackageName.getEditor().getEditorComponent() instanceof JTextField) {
        JTextField txt = (JTextField)comPackageName.getEditor().getEditorComponent();
        txt.getDocument().addDocumentListener(dListener);
    }
}
 
private void setUpChangeListeners(final DataSourceConfigurationAggregatingPanel
                                          aggregatingPanel,
                                  final ConfigurationChangeListener listener) {
    DocumentListener textFieldListener = new DocumentAdapter() {
        @Override
        protected void textChanged(DocumentEvent e) {
            listener.changeApplied(aggregatingPanel
                    .getCurrentConfigurationState());
        }
    };
    host.getComponent().getDocument().addDocumentListener(textFieldListener);
    port.getComponent().getDocument().addDocumentListener(textFieldListener);
    username.getComponent().getDocument().addDocumentListener(textFieldListener);
    password.getComponent().getDocument().addDocumentListener(textFieldListener);
    databaseName.getComponent().getDocument().addDocumentListener(textFieldListener);
}
 
源代码10 项目: netbeans   文件: PhpUnitOptionsPanel.java
@NbBundle.Messages({
    "# {0} - short script name",
    "# {1} - long script name",
    "# {2} - PHAR script name",
    "PhpUnitOptionsPanel.phpUnit.hint=<html>Full path of PHPUnit script (typically {0}, {1} or {2}).",
    "# {0} - short script name",
    "# {1} - long script name",
    "# {2} - PHAR script name",
    "PhpUnitOptionsPanel.skelGen.hint=<html>Full path of Skeleton Generator script (typically {0}, {1} or {2})."
})
private void init() {
    errorLabel.setText(" "); // NOI18N
    phpUnitHintLabel.setText(Bundle.PhpUnitOptionsPanel_phpUnit_hint(
            PhpUnit.SCRIPT_NAME, PhpUnit.SCRIPT_NAME_LONG, PhpUnit.SCRIPT_NAME_PHAR));
    skelGenHintLabel.setText(Bundle.PhpUnitOptionsPanel_skelGen_hint(
            SkeletonGenerator.SCRIPT_NAME, SkeletonGenerator.SCRIPT_NAME_LONG, SkeletonGenerator.SCRIPT_NAME_PHAR));

    DocumentListener defaultDocumentListener = new DefaultDocumentListener();
    phpUnitTextField.getDocument().addDocumentListener(defaultDocumentListener);
    skelGenTextField.getDocument().addDocumentListener(defaultDocumentListener);
}
 
源代码11 项目: netbeans   文件: CodeSnifferOptionsPanel.java
@NbBundle.Messages({
    "# {0} - short script name",
    "# {1} - long script name",
    "CodeSnifferOptionsPanel.hint=Full path of Code Sniffer script (typically {0} or {1}).",
})
private void initCodeSniffer(DocumentListener defaultDocumentListener) {
    codeSnifferHintLabel.setText(Bundle.CodeSnifferOptionsPanel_hint(CodeSniffer.NAME, CodeSniffer.LONG_NAME));
    codeSnifferStandardComboBox.setModel(codeSnifferStandardsModel);

    // listeners
    codeSnifferTextField.getDocument().addDocumentListener(defaultDocumentListener);
    codeSnifferTextField.getDocument().addDocumentListener(new CodeSnifferPathDocumentListener());
    final ItemListener defaultItemListener = new DefaultItemListener();
    codeSnifferStandardsModel.fetchStandards(codeSnifferStandardComboBox, new Runnable() {
        @Override
        public void run() {
            // #232279
            codeSnifferStandardComboBox.addItemListener(defaultItemListener);
        }
    });
}
 
源代码12 项目: netbeans   文件: ComposerOptionsPanel.java
@NbBundle.Messages({
    "# {0} - short script name",
    "# {1} - long script name",
    "ComposerOptionsPanel.composer.hint=Full path of Composer script (typically {0} or {1}).",
})
private void init() {
    hintLabel.setText(Bundle.ComposerOptionsPanel_composer_hint(Composer.COMPOSER_FILENAMES.get(0), Composer.COMPOSER_FILENAMES.get(1)));
    errorLabel.setText(" "); // NOI18N

    // listeners
    DocumentListener documentListener = new DefaultDocumentListener();
    composerTextField.getDocument().addDocumentListener(documentListener);
    vendorTextField.getDocument().addDocumentListener(documentListener);
    authorNameTextField.getDocument().addDocumentListener(documentListener);
    authorEmailTextField.getDocument().addDocumentListener(documentListener);
    ignoreVendorCheckBox.addItemListener(new DefaultItemListener());
}
 
源代码13 项目: netbeans   文件: TesterOptionsPanel.java
@NbBundle.Messages({
    "# {0} - nette tester file name",
    "TesterOptionsPanel.tester.hint=Full path of Nette Tester file (typically {0}).",
})
private void init() {
    for (String binaryExecutable : TesterUtils.BINARY_EXECUTABLES) {
        binaryExecutableComboBox.addItem(binaryExecutable);
    }
    errorLabel.setText(" "); // NOI18N
    testerPathHintLabel.setText(Bundle.TesterOptionsPanel_tester_hint(Tester.TESTER_FILE_NAME));

    DocumentListener defaultDocumentListener = new DefaultDocumentListener();
    ActionListener defaultActionListener = new DefaultActionListener();
    testerPathTextField.getDocument().addDocumentListener(defaultDocumentListener);
    phpIniTextField.getDocument().addDocumentListener(defaultDocumentListener);
    binaryExecutableComboBox.addActionListener(defaultActionListener);
}
 
源代码14 项目: darklaf   文件: DummyEditorPane.java
@Override
public void setLayout(final LayoutManager mgr) {
    if (mgr instanceof DocumentListener) {
        Document doc = getDocument();
        if (doc != null) doc.removeDocumentListener((DocumentListener) mgr);
    }
}
 
源代码15 项目: darklaf   文件: DummyTextComponent.java
@Override
public void setLayout(final LayoutManager mgr) {
    if (mgr instanceof DocumentListener) {
        Document doc = getDocument();
        if (doc != null) doc.removeDocumentListener((DocumentListener) mgr);
    }
}
 
源代码16 项目: netbeans   文件: BaseDocument.java
@Override
   public void removeDocumentListener(DocumentListener listener) {
       if (LOG_LISTENER.isLoggable(Level.FINE)) {
           LOG_LISTENER.fine("REMOVE DocumentListener of class " + listener.getClass() + " from existing " +
                   org.netbeans.lib.editor.util.swing.DocumentUtilities.getDocumentListenerCount(this) +
                   " listeners. Listener: " + listener + '\n'
           );
           if (LOG_LISTENER.isLoggable(Level.FINER)) {
               LOG_LISTENER.log(Level.FINER, "    StackTrace:\n", new Exception());
           }
       }
if (!org.netbeans.lib.editor.util.swing.DocumentUtilities.removePriorityDocumentListener(
               this, listener, DocumentListenerPriority.DEFAULT))
           super.removeDocumentListener(listener);
   }
 
源代码17 项目: mzmine2   文件: JFontSpecs.java
public void addListener(ColorChangedListener ccl, ItemListener il, DocumentListener dl) {
  fontBox.addItemListener(il);
  styleBox.addItemListener(il);
  txtSize.getDocument().addDocumentListener(dl);
  color.addColorChangedListener(ccl);
  if (dl instanceof DelayedDocumentListener)
    this.dl = (DelayedDocumentListener) dl;
}
 
源代码18 项目: netbeans   文件: WeakListenerImpl.java
/** Gives notification that an attribute or set of attributes changed.
* @param ev event describing the action
*/
@Override public void changedUpdate(DocumentEvent ev) {
    final DocumentListener l = docGet(ev);

    if (l != null) {
        l.changedUpdate(ev);
    }
}
 
源代码19 项目: netbeans   文件: WeakListenerImpl.java
/** Gives notification that a portion of the document has been removed.
* @param ev event describing the action
*/
@Override public void removeUpdate(DocumentEvent ev) {
    final DocumentListener l = docGet(ev);

    if (l != null) {
        l.removeUpdate(ev);
    }
}
 
源代码20 项目: netbeans   文件: WeakListenerImpl.java
/** Getter for the target listener.
* @param event the event the we want to distribute
* @return null if there is no listener because it has been finalized
*/
private DocumentListener docGet(DocumentEvent ev) {
    DocumentListener l = (DocumentListener) super.ref.get();

    if (l == null) {
        super.ref.requestCleanUp(ev.getDocument());
    }

    return l;
}
 
源代码21 项目: netbeans   文件: AbstractDocumentModel.java
private DocumentListener getDelegate() {
    DocumentListener l = delegate.get();
    if (l == null) {
	source.removeDocumentListener(this);
    }
    
    return l;
}
 
源代码22 项目: netbeans   文件: NewJetModuleWizardPanelUi.java
private void init() {
    setName(Bundle.NewJetModuleWizardPanelUi_name());
    DocumentListener defaultDocumentListener = new DefaultDocumentListener();
    nameTextField.getDocument().addDocumentListener(defaultDocumentListener);
    jsFolderTextField.getDocument().addDocumentListener(defaultDocumentListener);
    htmlFolderTextField.getDocument().addDocumentListener(defaultDocumentListener);
}
 
源代码23 项目: netbeans   文件: CustomizerKarma.java
private void addListeners() {
    DocumentListener defaultDocumentListener = new DefaultDocumentListener();
    ItemListener defaultItemListener = new DefaultItemListener();
    ActionListener defaultActionListener = new DefaultActionListener();
    configTextField.getDocument().addDocumentListener(defaultDocumentListener);
    autowatchCheckBox.addItemListener(defaultItemListener);
    failOnErrorCheckBox.addItemListener(defaultItemListener);
    debugCheckBox.addItemListener(new DebugItemListener());
    debugBrowserIdComboBox.addActionListener(defaultActionListener);
}
 
源代码24 项目: ios-image-util   文件: SplitterFrame.java
/**
 * Initialize text field to size box.
 *
 * @param tooltipText tooltip text
 * @param focusListener
 * @param documentListener
 * @return
 */
private JTextField createSizeText(String tooltipText, FocusListener focusListener, DocumentListener documentListener) {
	JTextField textField = new JTextField("", 5);
	Insets insets = new Insets(2, 2, 2, 4);
	textField.setToolTipText(tooltipText);
	textField.setHorizontalAlignment(JTextField.RIGHT);
	textField.setMargin(insets);
	textField.addFocusListener(focusListener);
	textField.getDocument().addDocumentListener(documentListener);
	return textField;
}
 
源代码25 项目: netbeans   文件: QuickSearchPanel.java
QuickSearchPanel(WizardDescriptor settings, DataModel data) {
    super(settings);
    this.data = data;
    initComponents();

    putClientProperty("NewFileWizard_Title", getMessage("LBL_QuickSearchPanel_Title"));

    DocumentListener dListener = new UIUtil.DocumentAdapter() {

        public void insertUpdate(DocumentEvent e) {
            checkValidity();
        }
    };

    if (data.getPackageName() != null) {
        packageCombo.setSelectedItem(data.getPackageName());
    }

    classNameTextField.getDocument().addDocumentListener(dListener);
    categoryNameTextField.getDocument().addDocumentListener(dListener);
    commandPrefixTextField.getDocument().addDocumentListener(dListener);
    positionTextField.getDocument().addDocumentListener(dListener);
    Component editorComp = packageCombo.getEditor().getEditorComponent();
    if (editorComp instanceof JTextComponent) {
        ((JTextComponent) editorComp).getDocument().addDocumentListener(dListener);
    }
}
 
源代码26 项目: netbeans   文件: NameAndLocationPanel.java
/** Creates new NameAndLocationPanel */
public NameAndLocationPanel(final WizardDescriptor setting, final NewLoaderIterator.DataModel data) {
    super(setting);
    this.data = data;
    initComponents();
    initAccessibility();
    putClientProperty("NewFileWizard_Title", getMessage("LBL_LoaderWizardTitle"));
    
    DocumentListener dListener = new UIUtil.DocumentAdapter() {
        @Override
        public void insertUpdate(DocumentEvent e) {
            if (checkValidity()) {
                updateData();
            }
        }
    };
    txtPrefix.getDocument().addDocumentListener(dListener);
    txtIcon.getDocument().addDocumentListener(dListener);
    
    if (comPackageName.getEditor().getEditorComponent() instanceof JTextField) {
        JTextField txt = (JTextField)comPackageName.getEditor().getEditorComponent();
        txt.getDocument().addDocumentListener(dListener);
    }
    
    if (data.canUseMultiview()) {
        useMultiView.setEnabled(true);
        useMultiView.setSelected(true);
    } else {
        useMultiView.setEnabled(false);
        useMultiView.setSelected(false);
    }
}
 
源代码27 项目: netbeans   文件: CodeGeneratorPanel.java
/** Creates new form CodeGeneratorPanel */
CodeGeneratorPanel(WizardDescriptor settings, NewCodeGeneratorIterator.DataModel data) {
    super(settings);
    this.data = data;
    initComponents();
    
    putClientProperty("NewFileWizard_Title", getMessage("LBL_CodeGeneratorPanel_Title"));
    
    DocumentListener dListener = new UIUtil.DocumentAdapter() {
        public void insertUpdate(DocumentEvent e) {
            checkValidity();
        }
    };
    
    if (data.getPackageName() != null) {
        packageNameCombo.setSelectedItem(data.getPackageName());
    }
    
    fileNametextField.getDocument().addDocumentListener(dListener);
    cpFileNameField.getDocument().addDocumentListener(dListener);
    mimeTypeTextField.getDocument().addDocumentListener(dListener);
    Component editorComp = packageNameCombo.getEditor().getEditorComponent();
    if (editorComp instanceof JTextComponent) {
        ((JTextComponent) editorComp).getDocument().addDocumentListener(dListener);
    }
    
}
 
源代码28 项目: lippen-network-tool   文件: IPV4Field.java
public void removeDocumentListener(DocumentListener listener) {
    if (this.ipFields != null) {
        for (JIPV4Field field : this.ipFields) {
            field.getDocument().removeDocumentListener(listener);
        }
    }
}
 
源代码29 项目: netbeans   文件: GlassFishPassword.java
/**
 * Create event listener to validate account field on the fly.
 */
private DocumentListener initPasswordValidateListener() {
    return new ComponentFieldListener() {
        @Override
        void processEvent() {
            valid = passwordValid();
            setDescriptorButtons(descriptor, valid);
        }
    };
}
 
源代码30 项目: netbeans   文件: PhpDocPanel.java
private void init() {
    targetTextField.setText(PhpDocPreferences.getPhpDocTarget(phpModule, false));
    titleTextField.setText(PhpDocPreferences.getPhpDocTitle(phpModule));

    DocumentListener defaultDocumentListener = new DefaultDocumentListener();
    targetTextField.getDocument().addDocumentListener(defaultDocumentListener);
    titleTextField.getDocument().addDocumentListener(defaultDocumentListener);
}
 
 类所在包
 同包方法