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 File: NameAndLocationPanel.java    From netbeans with 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 #2
Source File: ConnectionParametersPanel.java    From intellij-xquery with 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 #3
Source File: PhpUnitOptionsPanel.java    From netbeans with 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 #4
Source File: OutputDocument.java    From netbeans with 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 #5
Source File: CodeSnifferOptionsPanel.java    From netbeans with 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 #6
Source File: SampleVisualPanel.java    From netbeans with 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 #7
Source File: NameAndLocationPanel.java    From netbeans with 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 #8
Source File: NewClientSideProject.java    From netbeans with 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 #9
Source File: SampleVisualPanel.java    From netbeans with 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 #10
Source File: ComposerOptionsPanel.java    From netbeans with 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 #11
Source File: NameAndLocationPanel.java    From netbeans with 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 #12
Source File: TesterOptionsPanel.java    From netbeans with 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 #13
Source File: BasicBrandingPanel.java    From netbeans with 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 #14
Source File: JFontSpecs.java    From mzmine2 with 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 #15
Source File: PhpDocPanel.java    From netbeans with 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);
}
 
Example #16
Source File: CodeceptionOptionsPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages({
    "# {0} - short script name",
    "# {1} - long script name",
    "# {2} - PHAR script name",
    "CodeceptionOptionsPanel.codeception.hint=<html>Full path of Codecept file (typically {0}, {1} or {2}).",
})
private void init() {
    errorLabel.setText(" "); // NOI18N
    codeceptionHintLabel.setText(Bundle.CodeceptionOptionsPanel_codeception_hint(Codecept.SCRIPT_NAME, Codecept.SCRIPT_NAME_LONG, Codecept.SCRIPT_NAME_PHAR));

    DocumentListener defaultDocumentListener = new DefaultDocumentListener();
    codeceptionTextField.getDocument().addDocumentListener(defaultDocumentListener);
}
 
Example #17
Source File: FileSelector.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Adds the document listener.
 *
 * @param l the l
 */
/*
 * (non-Javadoc)
 * 
 * @see java.awt.Component#addKeyListener(java.awt.event.KeyListener)
 */
public synchronized void addDocumentListener(DocumentListener l) {
  field.getDocument().addDocumentListener(l);
}
 
Example #18
Source File: BaseDocument.java    From netbeans with 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 #19
Source File: GlassFishPassword.java    From netbeans with 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 #20
Source File: WeakListenerImpl.java    From netbeans with 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 #21
Source File: WeakListenerImpl.java    From netbeans with 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 #22
Source File: IPV4Field.java    From lippen-network-tool with 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 #23
Source File: AbstractDocumentModel.java    From netbeans with 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 #24
Source File: SplitterFrame.java    From ios-image-util with 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 File: NewJetModuleWizardPanelUi.java    From netbeans with 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 #26
Source File: CodeGeneratorPanel.java    From netbeans with 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 #27
Source File: NameAndLocationPanel.java    From netbeans with 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 #28
Source File: QuickSearchPanel.java    From netbeans with 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 #29
Source File: CustomizerKarma.java    From netbeans with 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 #30
Source File: DummyEditorPane.java    From darklaf with 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);
    }
}