Java Code Examples for javax.swing.JComboBox#getInputMap()

The following examples show how to use javax.swing.JComboBox#getInputMap() . 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: FixDuplicateImportStmts.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private JComboBox createComboBox(DataItem item, Font font, FocusListener listener) {
    List<ItemVariant> variants = item.getVariants();
    JComboBox combo = new JComboBox(variants.toArray());
    combo.setSelectedItem(item.getDefaultVariant());
    combo.getAccessibleContext().setAccessibleDescription(getBundleString("FixDupImportStmts_Combo_ACSD")); //NOI18N
    combo.getAccessibleContext().setAccessibleName(getBundleString("FixDupImportStmts_Combo_Name_ACSD")); //NOI18N
    combo.setOpaque(false);
    combo.setFont(font);
    combo.addFocusListener(listener);
    combo.setEnabled(variants.size() > 1);
    combo.setRenderer(new DelegatingRenderer(combo.getRenderer(), variants, item.getVariantIcons()));
    InputMap inputMap = combo.getInputMap(JComboBox.WHEN_FOCUSED);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "showPopup"); //NOI18N
    combo.getActionMap().put("showPopup", new TogglePopupAction()); //NOI18N
    return combo;
}
 
Example 2
Source File: FixDuplicateImportStmts.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private JComboBox createComboBox(CandidateDescription[] choices, CandidateDescription defaultValue, Font font, FocusListener listener ) {
    JComboBox combo = new JComboBox(choices);
    combo.setSelectedItem(defaultValue);
    combo.getAccessibleContext().setAccessibleDescription(getBundleString("FixDupImportStmts_Combo_ACSD")); //NOI18N
    combo.getAccessibleContext().setAccessibleName(getBundleString("FixDupImportStmts_Combo_Name_ACSD")); //NOI18N
    combo.setOpaque(false);
    combo.setFont( font );
    combo.addFocusListener( listener );
    combo.setEnabled( choices.length > 1 );
    combo.setRenderer( new DelegatingRenderer(combo.getRenderer()));
    InputMap inputMap = combo.getInputMap( JComboBox.WHEN_FOCUSED );
    inputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_SPACE, 0), "showPopup" ); //NOI18N
    combo.getActionMap().put( "showPopup", new TogglePopupAction() ); //NOI18N
    return combo;
}
 
Example 3
Source File: ImportChooserInnerPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private JComboBox createComboBox( String[] choices, String defaultValue, Icon[] icons, Font font, FocusListener listener ) {
    JComboBox combo = new JComboBox(choices);
    combo.setSelectedItem(defaultValue);
    combo.getAccessibleContext().setAccessibleDescription(getBundleString("FixDupImportStmts_Combo_ACSD")); //NOI18N
    combo.getAccessibleContext().setAccessibleName(getBundleString("FixDupImportStmts_Combo_Name_ACSD")); //NOI18N
    combo.setOpaque(false);
    combo.setFont( font );
    combo.addFocusListener( listener );
    combo.setEnabled( choices.length > 1 );
    combo.setRenderer( new DelegatingRenderer(combo.getRenderer(), choices, icons ) );
    InputMap inputMap = combo.getInputMap( JComboBox.WHEN_FOCUSED );
    inputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_SPACE, 0), "showPopup" ); //NOI18N
    combo.getActionMap().put( "showPopup", new TogglePopupAction() ); //NOI18N
    return combo;
}
 
Example 4
Source File: FixDuplicateImportStmts.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private JComboBox createComboBox(DataItem item, Font font, FocusListener listener) {
    List<VariantItem> variants = item.getVariants();
    JComboBox combo = new JComboBox(variants.toArray());
    combo.setSelectedItem(item.getDefaultVariant());
    combo.getAccessibleContext().setAccessibleDescription(getBundleString("FixDupImportStmts_Combo_ACSD")); //NOI18N
    combo.getAccessibleContext().setAccessibleName(getBundleString("FixDupImportStmts_Combo_Name_ACSD")); //NOI18N
    combo.setOpaque(false);
    combo.setFont(font);
    combo.addFocusListener(listener);
    combo.setEnabled(variants.size() > 1);
    InputMap inputMap = combo.getInputMap(JComboBox.WHEN_FOCUSED);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "showPopup"); //NOI18N
    combo.getActionMap().put("showPopup", new TogglePopupAction()); //NOI18N
    return combo;
}