本文整理汇总了Java中javax.swing.JComboBox.setOpaque方法的典型用法代码示例。如果您正苦于以下问题:Java JComboBox.setOpaque方法的具体用法?Java JComboBox.setOpaque怎么用?Java JComboBox.setOpaque使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JComboBox
的用法示例。
在下文中一共展示了JComboBox.setOpaque方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createComboBox
import javax.swing.JComboBox; //导入方法依赖的package包/类
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;
}
示例2: initComponents
import javax.swing.JComboBox; //导入方法依赖的package包/类
private void initComponents() {
setLayout(new BorderLayout(4, 0));
setBorder(new EmptyBorder(0, 2, 0, 8));
setOpaque(false);
setFocusTraversalPolicyProvider(true);
setFocusTraversalPolicy(new DefaultFocusTraversalPolicy() {
@Override
public Component getDefaultComponent(Container aContainer) {
if (!SwingUtilities.isEventDispatchThread()) {
return null;
}
final EditorCookie ec = actionContext.lookup(
EditorCookie.class);
if (ec != null) {
JEditorPane[] panes = ec.getOpenedPanes();
if (panes != null) {
for (JEditorPane pane : panes) {
if (pane.isShowing()) {
return pane;
}
}
}
}
return null;
}
});
combo = new JComboBox();
combo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
DatabaseConnection dbconn = (DatabaseConnection)combo.getSelectedItem();
combo.setToolTipText(dbconn != null ? dbconn.getDisplayName() : null);
}
});
combo.setOpaque(false);
combo.setModel(new DefaultComboBoxModel(
new String[] { NbBundle.getMessage(ToolbarPresenter.class, "ConnectionAction.ToolbarPresenter.LoadingConnections") }));
combo.setRenderer(new DatabaseConnectionRenderer());
String accessibleName = NbBundle.getMessage(ConnectionAction.class, "LBL_DatabaseConnection");
combo.getAccessibleContext().setAccessibleName(accessibleName);
combo.getAccessibleContext().setAccessibleDescription(accessibleName);
combo.setPreferredSize (new Dimension (400, combo.getPreferredSize ().height));
add(combo, BorderLayout.CENTER);
comboLabel = new JLabel();
Mnemonics.setLocalizedText(comboLabel, NbBundle.getMessage(ConnectionAction.class, "LBL_ConnectionAction"));
comboLabel.setOpaque(false);
comboLabel.setLabelFor(combo);
add(comboLabel, BorderLayout.WEST);
}