javax.swing.JComboBox#setPopupVisible ( )源码实例Demo

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

源代码1 项目: netbeans   文件: ReturnTypeUIHelper.java
private static void performBrowseType(final JComboBox combo, final ClasspathInfo cpInfo) {
    final ReturnTypeComboBoxModel model = (ReturnTypeComboBoxModel) combo.getModel();
    combo.setPopupVisible(false);
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            final ElementHandle<TypeElement> handle = TypeElementFinder.find(cpInfo, new TypeElementFinder.Customizer() {
                public Set<ElementHandle<TypeElement>> query(ClasspathInfo classpathInfo, String textForQuery, NameKind nameKind, Set<SearchScope> searchScopes) {//GEN-LAST:event_browseButtonActionPerformed
                    return classpathInfo.getClassIndex().getDeclaredTypes(textForQuery, nameKind, searchScopes);
                }

                public boolean accept(ElementHandle<TypeElement> typeHandle) {
                    return true;
                }
            });

            combo.setPopupVisible(false);
            
            if (handle == null) {
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        setSelectedItem(combo, model.getPreviousItem());
                    }
                });
            } else {
                setSelectedItem(combo, handle.getQualifiedName());
            }
        }
    });
}
 
源代码2 项目: netbeans   文件: FixDuplicateImportStmts.java
@Override
public void actionPerformed(ActionEvent e) {
    if (e.getSource() instanceof JComboBox) {
        JComboBox combo = (JComboBox) e.getSource();
        combo.setPopupVisible(!combo.isPopupVisible());
    }
}
 
源代码3 项目: netbeans   文件: FixDuplicateImportStmts.java
@Override
public void actionPerformed(ActionEvent e) {
    if (e.getSource() instanceof JComboBox) {
        JComboBox combo = (JComboBox) e.getSource();
        combo.setPopupVisible(!combo.isPopupVisible());
    }
}
 
源代码4 项目: netbeans   文件: DataComboBoxSupport.java
@Override
public void actionPerformed(ActionEvent e) {
    final JComboBox comboBox = (JComboBox)e.getSource();

    Object selectedItem = comboBox.getSelectedItem();
    if (selectedItem == NEW_ITEM) {
        performingNewItemAction = true;
        try {
            comboBox.setPopupVisible(false);
            dataModel.newItemActionPerformed();
        } finally {
            performingNewItemAction = false;
        }

        setPreviousNonSpecialItem(comboBox);
        // we (or maybe the client) have just selected an item inside an actionPerformed event,
        // which will not send another actionPerformed event for the new item. 
        // We need to make sure all listeners get an event for the new item,
        // thus...
        final Object newSelectedItem = comboBox.getSelectedItem();
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                comboBox.setSelectedItem(newSelectedItem);
            }
        });
    }
}
 
源代码5 项目: netbeans   文件: ResolveDeclarationsPanel.java
@Override
public void actionPerformed(ActionEvent e) {
    if (e.getSource() instanceof JComboBox) {
        JComboBox combo = (JComboBox) e.getSource();
        combo.setPopupVisible(!combo.isPopupVisible());
    }
}
 
源代码6 项目: netbeans   文件: FixDuplicateImportStmts.java
public void actionPerformed(ActionEvent e) {
    if( e.getSource() instanceof JComboBox ) {
        JComboBox combo = (JComboBox)e.getSource();
        combo.setPopupVisible( !combo.isPopupVisible() );
    }
}
 
源代码7 项目: netbeans   文件: ImportChooserInnerPanel.java
public void actionPerformed(ActionEvent e) {
    if( e.getSource() instanceof JComboBox ) {
        JComboBox combo = (JComboBox)e.getSource();
        combo.setPopupVisible( !combo.isPopupVisible() );
    }
}
 
源代码8 项目: cropplanning   文件: AutoCompleteDecorator.java
/**
 * Enables automatic completion for the given JComboBox. The automatic
 * completion will be strict (only items from the combo box can be selected)
 * if the combo box is not editable.
 * @param comboBox a combo box
 * @param stringConverter the converter used to transform items to strings
 */
public static void decorate(final JComboBox comboBox, final ObjectToStringConverter stringConverter) {
    boolean strictMatching = !comboBox.isEditable();
    // has to be editable
    comboBox.setEditable(true);
    // fix the popup location
    AquaLnFPopupLocationFix.install(comboBox);

    // configure the text component=editor component
    JTextComponent editorComponent = (JTextComponent) comboBox.getEditor().getEditorComponent();
    final AbstractAutoCompleteAdaptor adaptor = new ComboBoxAdaptor(comboBox);
    final AutoCompleteDocument document = new AutoCompleteDocument(adaptor, strictMatching, stringConverter);
    decorate(editorComponent, document, adaptor);
    
    // show the popup list when the user presses a key
    final KeyListener keyListener = new KeyAdapter() {
        public void keyPressed(KeyEvent keyEvent) {
            // don't popup on action keys (cursor movements, etc...)
            if (keyEvent.isActionKey()) return;
            // don't popup if the combobox isn't visible anyway
            if (comboBox.isDisplayable() && !comboBox.isPopupVisible()) {
                int keyCode = keyEvent.getKeyCode();
                // don't popup when the user hits shift,ctrl or alt
                if (keyCode==keyEvent.VK_SHIFT || keyCode==keyEvent.VK_CONTROL || keyCode==keyEvent.VK_ALT) return;
                // don't popup when the user hits escape (see issue #311)
                if (keyCode==keyEvent.VK_ESCAPE) return;
                comboBox.setPopupVisible(true);
            }
        }
    };
    editorComponent.addKeyListener(keyListener);
    
    if (stringConverter!=ObjectToStringConverter.DEFAULT_IMPLEMENTATION) {
        comboBox.setEditor(new AutoCompleteComboBoxEditor(comboBox.getEditor(), stringConverter));
    }
    
    // Changing the l&f can change the combobox' editor which in turn
    // would not be autocompletion-enabled. The new editor needs to be set-up.
    comboBox.addPropertyChangeListener("editor", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
          	ComboBoxEditor editor = (ComboBoxEditor) e.getNewValue();
          	if (editor!=null && editor.getEditorComponent()!=null) {
                if (!(editor instanceof AutoCompleteComboBoxEditor) 
                    && stringConverter!=ObjectToStringConverter.DEFAULT_IMPLEMENTATION) {
                    comboBox.setEditor(new AutoCompleteComboBoxEditor(editor, stringConverter));
                    // Don't do the decorate step here because calling setEditor will trigger
                    // the propertychange listener a second time, which will do the decorate
                    // and addKeyListener step.
                } else {
                    decorate((JTextComponent) editor.getEditorComponent(), document, adaptor);
                    editor.getEditorComponent().addKeyListener(keyListener);
                }
          	}
        }
    });
}