Java Code Examples for javax.swing.JComboBox.getEditor()

The following are Jave code examples for showing how to use getEditor() of the javax.swing.JComboBox class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: incubator-netbeans   File: ComboBoxAutoCompleteSupport.java   Source Code and License Vote up 5 votes
public static boolean install( JComboBox combo ) {
    boolean res = false;
    ComboBoxEditor comboEditor = combo.getEditor();
    if( comboEditor.getEditorComponent() instanceof JTextComponent ) {
        JTextComponent textEditor = ( JTextComponent ) comboEditor.getEditorComponent();
        Document doc = textEditor.getDocument();
        doc.addDocumentListener( new AutoCompleteListener( combo ) );
        setIgnoreSelectionEvents( combo, false );
        combo.setEditable( true );
        res = true;
    }
    combo.putClientProperty( "nb.combo.autocomplete", res ); //NOI18N
    return res;
}
 
Example 2
Project: incubator-netbeans   File: ComboBoxAutoCompleteSupport.java   Source Code and License Vote up 5 votes
public static boolean install( JComboBox combo ) {
    boolean res = false;
    ComboBoxEditor comboEditor = combo.getEditor();
    if( comboEditor.getEditorComponent() instanceof JTextComponent ) {
        JTextComponent textEditor = ( JTextComponent ) comboEditor.getEditorComponent();
        Document doc = textEditor.getDocument();
        doc.addDocumentListener( new AutoCompleteListener( combo ) );
        setIgnoreSelectionEvents( combo, false );
        combo.setEditable( true );
        res = true;
    }
    combo.putClientProperty( "nb.combo.autocomplete", res ); //NOI18N
    return res;
}
 
Example 3
Project: incubator-netbeans   File: ReturnTypeUIHelper.java   Source Code and License Vote up 5 votes
private static void setSelectedItem(final JComboBox combo, final Object item) {
    combo.setSelectedItem(item);
    if (combo.isEditable() && combo.getEditor() != null) {
        // item must be set in the editor in case of editable combobox
        combo.configureEditor(combo.getEditor(), combo.getSelectedItem()); 
    }
}