javax.swing.event.DocumentListener Java Examples

The following examples show how to use javax.swing.event.DocumentListener. 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 Project: netbeans   Author: apache   File: OutputDocument.java    License: Apache License 2.0 6 votes vote down vote up
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;
    }
}
 
Example #2
Source Project: netbeans   Author: apache   File: SampleVisualPanel.java    License: Apache License 2.0 6 votes vote down vote up
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
    
}
 
Example #3
Source Project: netbeans   Author: apache   File: NewClientSideProject.java    License: Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #4
Source Project: netbeans   Author: apache   File: SampleVisualPanel.java    License: Apache License 2.0 6 votes vote down vote up
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
    
}
 
Example #5
Source Project: netbeans   Author: apache   File: BasicBrandingPanel.java    License: Apache License 2.0 6 votes vote down vote up
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 #6
Source Project: netbeans   Author: apache   File: NameAndLocationPanel.java    License: Apache License 2.0 6 votes vote down vote up
/** 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);        
}
 
Example #7
Source Project: netbeans   Author: apache   File: NameAndLocationPanel.java    License: Apache License 2.0 6 votes vote down vote up
/** 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);
    }
}
 
Example #8
Source Project: netbeans   Author: apache   File: NameAndLocationPanel.java    License: Apache License 2.0 6 votes vote down vote up
/** 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);
    }
}
 
Example #9
Source Project: intellij-xquery   Author: ligasgr   File: ConnectionParametersPanel.java    License: Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #10
Source Project: netbeans   Author: apache   File: PhpUnitOptionsPanel.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #11
Source Project: netbeans   Author: apache   File: CodeSnifferOptionsPanel.java    License: Apache License 2.0 6 votes vote down vote up
@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);
        }
    });
}
 
Example #12
Source Project: netbeans   Author: apache   File: ComposerOptionsPanel.java    License: Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example #13
Source Project: netbeans   Author: apache   File: TesterOptionsPanel.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #14
Source Project: darklaf   Author: weisJ   File: DummyEditorPane.java    License: MIT License 5 votes vote down vote up
@Override
public void setLayout(final LayoutManager mgr) {
    if (mgr instanceof DocumentListener) {
        Document doc = getDocument();
        if (doc != null) doc.removeDocumentListener((DocumentListener) mgr);
    }
}
 
Example #15
Source Project: darklaf   Author: weisJ   File: DummyTextComponent.java    License: MIT License 5 votes vote down vote up
@Override
public void setLayout(final LayoutManager mgr) {
    if (mgr instanceof DocumentListener) {
        Document doc = getDocument();
        if (doc != null) doc.removeDocumentListener((DocumentListener) mgr);
    }
}
 
Example #16
Source Project: netbeans   Author: apache   File: BaseDocument.java    License: Apache License 2.0 5 votes vote down vote up
@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);
   }
 
Example #17
Source Project: mzmine2   Author: mzmine   File: JFontSpecs.java    License: GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #18
Source Project: netbeans   Author: apache   File: WeakListenerImpl.java    License: Apache License 2.0 5 votes vote down vote up
/** 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);
    }
}
 
Example #19
Source Project: netbeans   Author: apache   File: WeakListenerImpl.java    License: Apache License 2.0 5 votes vote down vote up
/** 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);
    }
}
 
Example #20
Source Project: netbeans   Author: apache   File: WeakListenerImpl.java    License: Apache License 2.0 5 votes vote down vote up
/** 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;
}
 
Example #21
Source Project: netbeans   Author: apache   File: AbstractDocumentModel.java    License: Apache License 2.0 5 votes vote down vote up
private DocumentListener getDelegate() {
    DocumentListener l = delegate.get();
    if (l == null) {
	source.removeDocumentListener(this);
    }
    
    return l;
}
 
Example #22
Source Project: netbeans   Author: apache   File: NewJetModuleWizardPanelUi.java    License: Apache License 2.0 5 votes vote down vote up
private void init() {
    setName(Bundle.NewJetModuleWizardPanelUi_name());
    DocumentListener defaultDocumentListener = new DefaultDocumentListener();
    nameTextField.getDocument().addDocumentListener(defaultDocumentListener);
    jsFolderTextField.getDocument().addDocumentListener(defaultDocumentListener);
    htmlFolderTextField.getDocument().addDocumentListener(defaultDocumentListener);
}
 
Example #23
Source Project: netbeans   Author: apache   File: CustomizerKarma.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #24
Source Project: ios-image-util   Author: gootara-org   File: SplitterFrame.java    License: MIT License 5 votes vote down vote up
/**
 * 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;
}
 
Example #25
Source Project: netbeans   Author: apache   File: QuickSearchPanel.java    License: Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #26
Source Project: netbeans   Author: apache   File: NameAndLocationPanel.java    License: Apache License 2.0 5 votes vote down vote up
/** 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);
    }
}
 
Example #27
Source Project: netbeans   Author: apache   File: CodeGeneratorPanel.java    License: Apache License 2.0 5 votes vote down vote up
/** 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);
    }
    
}
 
Example #28
Source Project: lippen-network-tool   Author: okou19900722   File: IPV4Field.java    License: Apache License 2.0 5 votes vote down vote up
public void removeDocumentListener(DocumentListener listener) {
    if (this.ipFields != null) {
        for (JIPV4Field field : this.ipFields) {
            field.getDocument().removeDocumentListener(listener);
        }
    }
}
 
Example #29
Source Project: netbeans   Author: apache   File: GlassFishPassword.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Create event listener to validate account field on the fly.
 */
private DocumentListener initPasswordValidateListener() {
    return new ComponentFieldListener() {
        @Override
        void processEvent() {
            valid = passwordValid();
            setDescriptorButtons(descriptor, valid);
        }
    };
}
 
Example #30
Source Project: netbeans   Author: apache   File: PhpDocPanel.java    License: Apache License 2.0 5 votes vote down vote up
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);
}