本文整理汇总了Java中javax.swing.JComboBox.setEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java JComboBox.setEnabled方法的具体用法?Java JComboBox.setEnabled怎么用?Java JComboBox.setEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JComboBox
的用法示例。
在下文中一共展示了JComboBox.setEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initGapValues
import javax.swing.JComboBox; //导入方法依赖的package包/类
private static void initGapValues(EditableGap eg, JComboBox sizeCombo, JCheckBox resCheckBox) {
if (eg != null) {
String selected = null;
String[] defaultNames = eg.getPaddingDisplayNames();
if (eg.canHaveDefaultValue() && defaultNames != null) {
sizeCombo.setModel(new DefaultComboBoxModel(defaultNames));
if (eg.definedSize == LayoutConstants.NOT_EXPLICITLY_DEFINED) {
LayoutConstants.PaddingType[] defaultTypes = eg.getPossiblePaddingTypes();
if (eg.paddingType == null || defaultTypes == null || defaultTypes.length == 0) {
selected = defaultNames[0];
} else {
for (int i=0; i < defaultTypes.length; i++) {
if (eg.paddingType == defaultTypes[i]) {
selected = defaultNames[i];
break;
}
}
}
}
}
if (selected == null) {
selected = Integer.toString(eg.definedSize);
}
sizeCombo.setSelectedItem(selected);
resCheckBox.setSelected(eg.resizing);
} else {
sizeCombo.setSelectedItem(NbBundle.getMessage(EditLayoutSpacePanel.class, "VALUE_NoEmptySpace")); // NOI18N
sizeCombo.setEnabled(false);
resCheckBox.setEnabled(false);
}
}
示例2: 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;
}
示例3: checkAntScript
import javax.swing.JComboBox; //导入方法依赖的package包/类
private void checkAntScript(JComboBox combo, String antScript, String targetScript) {
if ((antScript == null && targetScript == null) ||
(antScript != null && antScript.equals(targetScript))) {
combo.setEnabled(true);
} else {
combo.setEnabled(false);
}
}
示例4: setEmptyModel
import javax.swing.JComboBox; //导入方法依赖的package包/类
private void setEmptyModel(JComboBox combo) {
if (combo != null) {
combo.setModel(WizardUtils.createComboEmptyModel());
combo.setEnabled(false);
combo.setEditable(false);
checkValidity();
}
}
示例5: getControls
import javax.swing.JComboBox; //导入方法依赖的package包/类
public java.awt.Component getControls() {
if (p == null) {
super.getControls();
nameField.addFocusListener(this);
dropList = new JComboBox(optionsModel);
dropList.setSelectedIndex(0);
dropList.setEnabled(false);
dropList.addActionListener(this);
setListVisibility();
p.add(dropList);
}
return p;
}
示例6: getNewTypeCombobox
import javax.swing.JComboBox; //导入方法依赖的package包/类
/** Returns the combobox for the new label's type. */
private JComboBox<String> getNewTypeCombobox() {
if (this.newTypeChoice == null) {
final JComboBox<String> result = this.newTypeChoice = new JComboBox<>();
for (EdgeRole kind : EdgeRole.values()) {
result.addItem(kind.getDescription(true));
}
result.setSelectedIndex(EdgeRole.getIndex(getOldLabel().getRole()));
result.setEnabled(true);
result.setFocusable(false);
result.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Font font = getNewField().getFont();
int fontProperty;
switch (EdgeRole.getRole(result.getSelectedIndex())) {
case NODE_TYPE:
fontProperty = Font.BOLD;
break;
case FLAG:
fontProperty = Font.ITALIC;
break;
default:
fontProperty = Font.PLAIN;
}
font = font.deriveFont(fontProperty);
getNewField().setFont(font);
setReplaceEnabled();
}
});
}
return this.newTypeChoice;
}
示例7: itemStateChanged
import javax.swing.JComboBox; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void itemStateChanged(ItemEvent e) {
// When the unit type changes, we have to reset the role choices
JComboBox<String> box = this.roleUI.getComponent();
DefaultComboBoxModel<String> model;
boolean enable = false;
UnitType type = (UnitType)this.typeUI.getComponent().getSelectedItem();
if (type != null && type.hasAbility(Ability.CAN_BE_EQUIPPED)) {
final Specification spec = type.getSpecification();
final NationType nt = getOption().getNationType();
int n = 0;
model = new DefaultComboBoxModel<>();
for (String ri : getOption().getRole().getChoices()) {
Role role = spec.getRole(ri);
if (role.isAvailableTo(type, nt)) {
model.addElement(ri);
n++;
}
}
enable = isEditable() && n > 1;
} else {
model = new DefaultComboBoxModel<>(new String[] {
Specification.DEFAULT_ROLE_ID });
}
box.setModel(model);
box.setEnabled(enable);
}
示例8: stylizeComboBox_disabled
import javax.swing.JComboBox; //导入方法依赖的package包/类
public void stylizeComboBox_disabled(JComboBox c){
c.setFont(font_14_bold);
((JLabel)c.getRenderer()).setHorizontalAlignment(JLabel.CENTER);
c.setForeground(Color.BLACK);
c.setBackground(new Color(26, 29, 35));
c.setEnabled(false);
}
示例9: stylizeComboBox
import javax.swing.JComboBox; //导入方法依赖的package包/类
public void stylizeComboBox(JComboBox c){
c.setFont(font_14_bold);
((JLabel)c.getRenderer()).setHorizontalAlignment(JLabel.CENTER);
c.setForeground(Color.BLACK);
c.setBackground(Color.WHITE);
c.setEnabled(true);
}
示例10: HierarchyTopComponent
import javax.swing.JComboBox; //导入方法依赖的package包/类
@NbBundle.Messages({
"TXT_NonActiveContent=<No View Available - Refresh Manually>",
"TXT_InspectHierarchyHistory=<empty>",
"TOOLTIP_RefreshContent=Refresh for entity under cursor",
"TOOLTIP_OpenJDoc=Open Javadoc Window",
"TOOLTIP_ViewHierarchyType=Hierachy View Type",
"TOOLTIP_InspectHierarchyHistory=Inspect Hierarchy History"
})
public HierarchyTopComponent() {
history = HistorySupport.getInstnace(this.getClass());
jdocFinder = SelectJavadocTask.create(this);
jdocTask = RP.create(jdocFinder);
explorerManager = new ExplorerManager();
rootChildren = new RootChildren();
filters = new HierarchyFilters();
explorerManager.setRootContext(Nodes.rootNode(rootChildren, filters));
selectedNodes = new InstanceContent();
lookup = new AbstractLookup(selectedNodes);
explorerManager.addPropertyChangeListener(this);
initComponents();
setName(Bundle.CTL_HierarchyTopComponent());
setToolTipText(Bundle.HINT_HierarchyTopComponent());
viewTypeCombo = new JComboBox(new DefaultComboBoxModel(ViewType.values()));
viewTypeCombo.setMinimumSize(new Dimension(MIN_TYPE_WIDTH,COMBO_HEIGHT));
viewTypeCombo.addActionListener(this);
viewTypeCombo.setToolTipText(Bundle.TOOLTIP_ViewHierarchyType());
historyCombo = new JComboBox(HistorySupport.createModel(history, Bundle.TXT_InspectHierarchyHistory()));
historyCombo.setMinimumSize(new Dimension(MIN_HISTORY_WIDTH,COMBO_HEIGHT));
historyCombo.setRenderer(HistorySupport.createRenderer(history));
historyCombo.addActionListener(this);
historyCombo.setEnabled(false);
historyCombo.getModel().addListDataListener(this);
historyCombo.setToolTipText(Bundle.TOOLTIP_InspectHierarchyHistory());
refreshButton = new JButton(ImageUtilities.loadImageIcon(REFRESH_ICON, true));
refreshButton.addActionListener(this);
refreshButton.setToolTipText(Bundle.TOOLTIP_RefreshContent());
jdocButton = new JButton(ImageUtilities.loadImageIcon(JDOC_ICON, true));
jdocButton.addActionListener(this);
jdocButton.setToolTipText(Bundle.TOOLTIP_OpenJDoc());
final Box upperToolBar = new MainToolBar(
constrainedComponent(viewTypeCombo, GridBagConstraints.HORIZONTAL, 1.0, new Insets(0,0,0,0)),
constrainedComponent(historyCombo, GridBagConstraints.HORIZONTAL, 1.5, new Insets(0,3,0,0)),
constrainedComponent(refreshButton, GridBagConstraints.NONE, 0.0, new Insets(0,3,0,0)),
constrainedComponent(jdocButton, GridBagConstraints.NONE, 0.0, new Insets(0,3,0,3)));
add(decorateAsUpperPanel(upperToolBar), BorderLayout.NORTH);
contentView = new JPanel();
contentView.setLayout(new CardLayout());
JPanel nonActiveContent = Utils.updateBackground(new JPanel());
nonActiveContent.setLayout(new BorderLayout());
nonActiveInfo = new JLabel(Bundle.TXT_NonActiveContent());
nonActiveInfo.setEnabled(false);
nonActiveInfo.setHorizontalAlignment(SwingConstants.CENTER);
nonActiveContent.add(nonActiveInfo, BorderLayout.CENTER);
btw = createBeanTreeView();
contentView.add(nonActiveContent, NON_ACTIVE_CONTENT);
contentView.add(btw, ACTIVE_CONTENT);
add(contentView,BorderLayout.CENTER);
lowerToolBar = new TapPanel();
lowerToolBar.setOrientation(TapPanel.DOWN);
final JComponent lowerButtons = filters.getComponent();
lowerButtons.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 0));
lowerToolBar.add(lowerButtons);
final boolean expanded = NbPreferences.forModule(HierarchyTopComponent.class).
getBoolean(PROP_LOWER_TOOLBAR_EXPANDED, true); //NOI18N
lowerToolBar.setExpanded(expanded);
lowerToolBar.addPropertyChangeListener(this);
add(Utils.updateBackground(lowerToolBar), BorderLayout.SOUTH);
}
示例11: ClassTable
import javax.swing.JComboBox; //导入方法依赖的package包/类
ClassTable() {
super(new ClassTableModel());
disabledCellRenderer = new DisabledCellRenderer();
//BEGIN Federico Dall'Orso 8/3/2005
//NEW
classTypeComboBoxCell = new ComboBoxCell(CLASS_TYPENAMES);
//todo sostituire quando saranno inserite le classi aperte
classTypeComboBoxCell.getComboBox().setEnabled(false);
deleteButton = new JButton(deleteOneClass);
deleteButtonCellRenderer = new ButtonCellEditor(deleteButton);
enableDeletes();
rowHeader.setRowHeight(CommonConstants.ROW_HEIGHT);
setRowHeight(CommonConstants.ROW_HEIGHT);
//END Federico Dall'Orso 8/3/2005
JComboBox classTypeBox = new JComboBox(CLASS_TYPENAMES);
//todo sostituire quando saranno inserite le classi aperte
classTypeBox.setEnabled(false);
classTypeCellEditor = new DefaultCellEditor(classTypeBox);
classTypeBox.setEditable(false);
setColumnSelectionAllowed(false);
setRowSelectionAllowed(true);
// not beautiful, but effective. See ClassTableModel.getColumnClass()
setDefaultRenderer(DisabledCellRenderer.class, disabledCellRenderer);
setDefaultEditor(String.class, classTypeCellEditor);
setDisplaysScrollLabels(true);
installKeyboardAction(getInputMap(), getActionMap(), deleteClass);
mouseHandler = new ExactTable.MouseHandler(makeMouseMenu());
mouseHandler.install();
help.addHelp(this,
"Click or drag to select classes; to edit data single-click and start typing. Right-click for a list of available operations");
help.addHelp(moreRowsLabel, "There are more classes: scroll down to see them");
help.addHelp(selectAllButton, "Click to select all classes");
tableHeader.setToolTipText(null);
rowHeader.setToolTipText(null);
help.addHelp(rowHeader, "Click, SHIFT-click or drag to select classes");
}
示例12: StationTable
import javax.swing.JComboBox; //导入方法依赖的package包/类
StationTable() {
super(new StationTableModel());
//BEGIN Federico Dall'Orso 8/3/2005
//station type cell renderers
//NEW
LD_disabled_StationTypeCell = new ComboBoxCell(STATION_TYPENAMES);
LD_disabled_StationTypeCell.getComboBox().setEnabled(false);
LD_enabled_StationTypeCell = new ComboBoxCell(STATION_TYPENAMES_LD_ENABLED);
LD_enabled_StationTypeCell.getComboBox().setEnabled(false);
//14/3/2005
deleteButton = new JButton(deleteOneStation);
deleteButtonCellRenderer = new ButtonCellEditor(deleteButton);
enableDeletes();
rowHeader.setRowHeight(CommonConstants.ROW_HEIGHT);
setRowHeight(CommonConstants.ROW_HEIGHT);
//END Federico Dall'Orso
/* a station type cell editor for open/mixed systems */
JComboBox stationTypeBox = new JComboBox(STATION_TYPENAMES);
stationTypeBox.setEditable(false);
stationTypeBox.setEnabled(false);
LD_disabled_StationTypeEditor = new DefaultCellEditor(stationTypeBox);
stationTypeBox.setEnabled(false);
/* a station type cell editor for closed systems */
JComboBox LD_enabled_StationTypeBox = new JComboBox(STATION_TYPENAMES_LD_ENABLED);
LD_enabled_StationTypeBox.setEditable(false);
LD_enabled_StationTypeBox.setEnabled(false);
LD_enabled_StationTypeEditor = new DefaultCellEditor(LD_enabled_StationTypeBox);
LD_enabled_StationTypeBox.setEnabled(false);
setColumnSelectionAllowed(false);
setRowSelectionAllowed(true);
setDisplaysScrollLabels(true);
installKeyboardAction(getInputMap(), getActionMap(), deleteStation);
mouseHandler = new ExactTable.MouseHandler(makeMouseMenu());
mouseHandler.install();
help.addHelp(this,
"Click or drag to select stations; to edit data single-click and start typing. Right-click for a list of available operations");
help.addHelp(moreRowsLabel, "There are more stations: scroll down to see them");
help.addHelp(selectAllButton, "Click to select all stations");
tableHeader.setToolTipText(null);
rowHeader.setToolTipText(null);
help.addHelp(rowHeader, "Click, SHIFT-click or drag to select stations");
}
示例13: ClassTable
import javax.swing.JComboBox; //导入方法依赖的package包/类
ClassTable() {
super(new ClassTableModel());
disabledCellRenderer = new DisabledCellRenderer();
//BEGIN Federico Dall'Orso 8/3/2005
//NEW
classTypeComboBoxCell = new ComboBoxCell(CLASS_TYPENAMES);
//todo sostituire quando saranno inserite le classi aperte
classTypeComboBoxCell.getComboBox().setEnabled(false);
deleteButton = new JButton(deleteOneClass);
deleteButtonCellRenderer = new ButtonCellEditor(deleteButton);
enableDeletes();
rowHeader.setRowHeight(18);
setRowHeight(18);
//END Federico Dall'Orso 8/3/2005
JComboBox classTypeBox = new JComboBox(CLASS_TYPENAMES);
//todo sostituire quando saranno inserite le classi aperte
classTypeBox.setEnabled(false);
classTypeCellEditor = new DefaultCellEditor(classTypeBox);
classTypeBox.setEditable(false);
setColumnSelectionAllowed(false);
setRowSelectionAllowed(true);
// not beautiful, but effective. See ClassTableModel.getColumnClass()
setDefaultRenderer(DisabledCellRenderer.class, disabledCellRenderer);
setDefaultEditor(String.class, classTypeCellEditor);
setDisplaysScrollLabels(true);
installKeyboardAction(getInputMap(), getActionMap(), deleteClass);
mouseHandler = new ExactTable.MouseHandler(makeMouseMenu());
mouseHandler.install();
help.addHelp(this,
"Click or drag to select classes; to edit data single-click and start typing. Right-click for a list of available operations");
help.addHelp(moreRowsLabel, "There are more classes: scroll down to see them");
help.addHelp(selectAllButton, "Click to select all classes");
tableHeader.setToolTipText(null);
rowHeader.setToolTipText(null);
help.addHelp(rowHeader, "Click, SHIFT-click or drag to select classes");
}
示例14: StationTable
import javax.swing.JComboBox; //导入方法依赖的package包/类
StationTable() {
super(new StationTableModel());
//BEGIN Federico Dall'Orso 8/3/2005
//station type cell renderers
//NEW
LD_disabled_StationTypeCell = new ComboBoxCell(STATION_TYPENAMES);
LD_disabled_StationTypeCell.getComboBox().setEnabled(false);
LD_enabled_StationTypeCell = new ComboBoxCell(STATION_TYPENAMES_LD_ENABLED);
LD_enabled_StationTypeCell.getComboBox().setEnabled(false);
//14/3/2005
deleteButton = new JButton(deleteOneStation);
deleteButtonCellRenderer = new ButtonCellEditor(deleteButton);
enableDeletes();
rowHeader.setRowHeight(18);
setRowHeight(18);
//END Federico Dall'Orso
/* a station type cell editor for open/mixed systems */
JComboBox stationTypeBox = new JComboBox(STATION_TYPENAMES);
stationTypeBox.setEditable(false);
stationTypeBox.setEnabled(false);
LD_disabled_StationTypeEditor = new DefaultCellEditor(stationTypeBox);
stationTypeBox.setEnabled(false);
/* a station type cell editor for closed systems */
JComboBox LD_enabled_StationTypeBox = new JComboBox(STATION_TYPENAMES_LD_ENABLED);
LD_enabled_StationTypeBox.setEditable(false);
LD_enabled_StationTypeBox.setEnabled(false);
LD_enabled_StationTypeEditor = new DefaultCellEditor(LD_enabled_StationTypeBox);
LD_enabled_StationTypeBox.setEnabled(false);
setColumnSelectionAllowed(false);
setRowSelectionAllowed(true);
setDisplaysScrollLabels(true);
installKeyboardAction(getInputMap(), getActionMap(), deleteStation);
mouseHandler = new ExactTable.MouseHandler(makeMouseMenu());
mouseHandler.install();
help.addHelp(this,
"Click or drag to select stations; to edit data single-click and start typing. Right-click for a list of available operations");
help.addHelp(moreRowsLabel, "There are more stations: scroll down to see them");
help.addHelp(selectAllButton, "Click to select all stations");
tableHeader.setToolTipText(null);
rowHeader.setToolTipText(null);
help.addHelp(rowHeader, "Click, SHIFT-click or drag to select stations");
}
示例15: setup
import javax.swing.JComboBox; //导入方法依赖的package包/类
private void setup()
{
JLabel heading = new JLabel("<html><h2>Item Selection");
JLabel typeLabel = new JLabel("Type");
JLabel dirLabel = new JLabel("Source");
JLabel xsltLabel = new JLabel("XSLT");
JLabel requiredLabel = new JLabel("<html><b>Required:");
JLabel optionalLabel = new JLabel("<html><b>Optional:");
xsltTextField = new JTextField();
dirTextField = new JTextField();
xsltButton = new JButton("...");
dirButton = new JButton("...");
xsltTextField.setEditable(false);
dirTextField.setEditable(true);
xsltButton.addActionListener(this);
dirButton.addActionListener(this);
typeComboBox = new JComboBox();
typeComboBox.setEnabled(false);
dirChooser = new JFileChooser();
dirChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
xsltChooser = new JFileChooser();
xsltChooser.setFileFilter(new XSLTFileFilter());
final int height1 = typeComboBox.getPreferredSize().height;
final int height2 = xsltTextField.getPreferredSize().height;
final int height3 = optionalLabel.getPreferredSize().height;
final int height4 = heading.getPreferredSize().height;
final int width2 = xsltButton.getPreferredSize().width;
final int width3 = dirLabel.getPreferredSize().width + 5;
final int[] rows = new int[]{height4, height3, height1, height2, height3, height2};
final int[] cols = new int[]{width3, TableLayout.FILL, width2};
setLayout(new TableLayout(rows, cols, 5, 0));
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
add(heading, new Rectangle(0, 0, 2, 1));
add(requiredLabel, new Rectangle(0, 1, 3, 1));
add(typeLabel, new Rectangle(0, 2, 1, 1));
add(typeComboBox, new Rectangle(1, 2, 2, 1));
add(dirLabel, new Rectangle(0, 3, 1, 1));
add(dirTextField, new Rectangle(1, 3, 1, 1));
add(dirButton, new Rectangle(2, 3, 1, 1));
add(optionalLabel, new Rectangle(0, 4, 3, 1));
add(xsltLabel, new Rectangle(0, 5, 1, 1));
add(xsltTextField, new Rectangle(1, 5, 1, 1));
add(xsltButton, new Rectangle(2, 5, 1, 1));
}