Java Code Examples for javax.swing.JComboBox#setEnabled()
The following examples show how to use
javax.swing.JComboBox#setEnabled() .
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 |
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: AnimationObjectEditor.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
private void initSourceDestMotion(Motion m, JSpinner start, JCheckBox check, JSpinner dest, JComboBox motionType) { if(m == null) { check.setSelected(false); start.setEnabled(false); dest.setEnabled(false); return; } start.setValue(m.getSourceValue()); //if(m.getSourceValue() != m.getDestinationValue()) { check.setSelected(true); motionType.setEnabled(true); dest.setEnabled(true); start.setEnabled(true); //} else { // check.setSelected(false); //} motionType.setSelectedIndex(AnimationAccessor.getMotionType(m) - 1); dest.setValue(m.getDestinationValue()); }
Example 3
Source File: MarketEUR.java From btdex with GNU General Public License v3.0 | 6 votes |
@Override public JComponent getFieldEditor(String key, boolean editable, HashMap<String, String> fields) { if(key.equals(METHOD)) { JComboBox<String> combo = new JComboBox<String>(); combo.addItem(SEPA); combo.addItem(SEPA_INSTANT); combo.setSelectedIndex(0); combo.setEnabled(editable); String value = fields.get(key); if(value.equals(SEPA_INSTANT)) combo.setSelectedIndex(1); return combo; } return super.getFieldEditor(key, editable, fields); }
Example 4
Source File: SpacecraftFrame.java From FoxTelem with GNU General Public License v3.0 | 6 votes |
private JComboBox<String> addComboBoxRow(JPanel parent, String name, String tip, String[] values) { JPanel row = new JPanel(); row.setLayout(new GridLayout(1,2,5,5)); //row.setLayout(new FlowLayout(FlowLayout.LEFT)); JLabel lbl = new JLabel(name); JComboBox<String> checkBox = new JComboBox<String>(values); checkBox.setEnabled(true); checkBox.addItemListener(this); checkBox.setToolTipText(tip); lbl.setToolTipText(tip); row.add(lbl); row.add(checkBox); parent.add(row); parent.add(new Box.Filler(new Dimension(10,5), new Dimension(10,5), new Dimension(10,5))); return checkBox; }
Example 5
Source File: AbstractAdapterEditor.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
JComponent addComboField(JPanel parent, String labelText, String propertyName, boolean isRequired, boolean isEditable) { PropertyDescriptor propertyDescriptor = propertyContainer.getDescriptor(propertyName); propertyDescriptor.setNotEmpty(isRequired); PropertyEditor editor = PropertyEditorRegistry.getInstance().findPropertyEditor(propertyDescriptor); JComponent editorComponent = editor.createEditorComponent(propertyDescriptor, bindingContext); editorComponent.setMaximumSize(new Dimension(editorComponent.getMaximumSize().width, controlHeight)); editorComponent.setPreferredSize(new Dimension(editorComponent.getPreferredSize().width, controlHeight)); if (editorComponent instanceof JComboBox) { JComboBox comboBox = (JComboBox)editorComponent; comboBox.setEditable(isEditable); comboBox.setEnabled(isEditable); } JLabel jLabel = new JLabel(labelText); parent.add(jLabel); jLabel.setLabelFor(editorComponent); parent.add(editorComponent); return editorComponent; }
Example 6
Source File: GUIRegistrationPanel.java From netbeans with Apache License 2.0 | 5 votes |
private void setEmptyModel(JComboBox combo) { if (combo != null) { combo.setModel(WizardUtils.createComboEmptyModel()); combo.setEnabled(false); combo.setEditable(false); checkValidity(); } }
Example 7
Source File: ImportChooserInnerPanel.java From netbeans with Apache License 2.0 | 5 votes |
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 8
Source File: PropertiesDialog.java From collect-earth with MIT License | 5 votes |
public void handleVisibilityPlotLayout(JComboBox plotShape, JComboBox numberPoints, JComboBox distanceBetweenPoints, JComboBox distanceToFrame, JComboBox dotsSide, JComboBox distanceBetweenPlots, JLabel area, JLabel distanceOrRadiuslabel, JComboBox largeCentralPlotSide ) { numberPoints.setEnabled(false); distanceBetweenPoints.setEnabled(false); distanceToFrame.setEnabled(false); dotsSide.setEnabled(false); area.setVisible(false); distanceBetweenPlots.setVisible(false); distanceBetweenPlots.setEnabled(false); largeCentralPlotSide.setVisible( false ); largeCentralPlotSide.setEnabled(false); if (plotShape.getSelectedItem().equals(SAMPLE_SHAPE.SQUARE) || plotShape.getSelectedItem().equals(SAMPLE_SHAPE.SQUARE_WITH_LARGE_CENTRAL_PLOT) ) { numberPoints.setEnabled(true); distanceBetweenPoints.setEnabled(true); distanceToFrame.setEnabled(true); dotsSide.setEnabled(true); area.setVisible(true); distanceOrRadiuslabel.setText(Messages.getString("OptionWizard.36")); if( plotShape.getSelectedItem().equals(SAMPLE_SHAPE.SQUARE_WITH_LARGE_CENTRAL_PLOT) ) { largeCentralPlotSide.setVisible( true ); largeCentralPlotSide.setEnabled(true); } } else if (plotShape.getSelectedItem().equals(SAMPLE_SHAPE.CIRCLE) || plotShape.getSelectedItem().equals(SAMPLE_SHAPE.HEXAGON)) { distanceBetweenPoints.setEnabled(true); dotsSide.setEnabled(true); numberPoints.setEnabled(true); distanceOrRadiuslabel.setText("Radius"); } else if (plotShape.getSelectedItem().equals(SAMPLE_SHAPE.NFI_THREE_CIRCLES) || plotShape.getSelectedItem().equals(SAMPLE_SHAPE.NFI_FOUR_CIRCLES)) { dotsSide.setEnabled(true); distanceBetweenPoints.setEnabled(true); distanceBetweenPlots.setVisible(true); distanceBetweenPlots.setEnabled(true); distanceOrRadiuslabel.setText("Radius of the plots"); } }
Example 9
Source File: FixDuplicateImportStmts.java From netbeans with Apache License 2.0 | 5 votes |
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 10
Source File: AbstractUnitOptionUI.java From freecol with GNU General Public License v2.0 | 5 votes |
/** * {@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 = n > 1 && isEditable(); } else { model = new DefaultComboBoxModel<>(new String[] { Specification.DEFAULT_ROLE_ID }); } box.setModel(model); box.setEnabled(enable); }
Example 11
Source File: DGenerateCertificate.java From portecle with GNU General Public License v2.0 | 5 votes |
/** * Populate the signature algorithm combo box with the signature algorithms applicable to the key pair algorithm. * Also set a sane default selected item, and disable the combo box if it has less than 2 items. * * @param type key pair type * @param combo the combo box to populate */ private static void populateSigAlgs(KeyPairType type, JComboBox<SignatureType> combo) { combo.removeAllItems(); for (SignatureType st : SignatureType.valuesFor(type)) { combo.addItem(st); } combo.setSelectedItem(SignatureType.defaultFor(type)); combo.setEnabled(combo.getItemCount() > 1); }
Example 12
Source File: ComponentController.java From swingsane with Apache License 2.0 | 5 votes |
private void updateSourceModel(ComboBoxModel<String> sourceModel, String source) { JComboBox<String> sourceComboBox = components.getSourceComboBox(); sourceComboBox.setModel(sourceModel != null ? sourceModel : new DefaultComboBoxModel<String>()); sourceComboBox.setEnabled(sourceModel != null ? true : false); if (source != null) { sourceComboBox.setSelectedItem(source); } }
Example 13
Source File: SkillEditor.java From gcs with Mozilla Public License 2.0 | 5 votes |
private JComboBox<Object> createComboBox(Container parent, Object[] items, Object selection, String tooltip) { JComboBox<Object> combo = new JComboBox<>(items); combo.setToolTipText(Text.wrapPlainTextForToolTip(tooltip)); combo.setSelectedItem(selection); combo.addActionListener(this); combo.setMaximumRowCount(items.length); UIUtilities.setToPreferredSizeOnly(combo); combo.setEnabled(mIsEditable); parent.add(combo); return combo; }
Example 14
Source File: ComboBox.java From pdfxtk with Apache License 2.0 | 5 votes |
public void create(PropertiesPanel panel) { JLabel l =new JLabel(label); l.setForeground(required ? PropertiesPanel.REQUIRED : PropertiesPanel.NON_REQUIRED); panel.container.add(l, Awt.constraints(false)); JComboBox cb = new JComboBox(); cb.setEnabled(enabled); for(int i = 0; i < values.length; i++) cb.addItem(values[i]); cb.setSelectedItem(initialValue); panel.valuecmps.put(key, cb); panel.container.add(cb, Awt.constraints(unit == null)); if(unit != null) panel.container.add(new JLabel(unit), Awt.constraints(true)); }
Example 15
Source File: MagicEditionsComboBoxCellRenderer.java From MtgDesktopCompanion with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,int row, int column) { JComboBox<MagicEdition> cbo = UITools.createComboboxEditions((List<MagicEdition>) value,SIZE.SMALL); cbo.setEnabled(enable); return cbo; }
Example 16
Source File: EditLayoutSpacePanel.java From netbeans with Apache License 2.0 | 5 votes |
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); } }
Example 17
Source File: Richfaces4CustomizerPanelVisual.java From netbeans with Apache License 2.0 | 4 votes |
private void setLibrariesComboBox(JComboBox comboBox, List<String> items) { comboBox.setModel(new DefaultComboBoxModel(items.toArray())); comboBox.setEnabled(!items.isEmpty()); }
Example 18
Source File: HierarchyTopComponent.java From netbeans with Apache License 2.0 | 4 votes |
@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); }
Example 19
Source File: PropertiesDialog.java From collect-earth with MIT License | 4 votes |
private String calculateArea(JComboBox numberOfPoints, JComboBox distanceBetweenPoints, JComboBox distanceToFrame, JComboBox dotsSide) { double side = 0; try { int numberOfPointsI = ((ComboBoxItem) numberOfPoints.getSelectedItem()).getNumberOfPoints(); int distanceBetweenPointsI = Integer.parseInt((String) distanceBetweenPoints.getSelectedItem()); int distanceToFrameI = Integer.parseInt((String) distanceToFrame.getSelectedItem()); if (numberOfPointsI == 0 || numberOfPointsI == 1) { side = 2d * distanceToFrameI; if (oldSelectedDistance == null) { oldSelectedDistance = (String) distanceBetweenPoints.getSelectedItem(); distanceBetweenPoints.setEnabled(false); } distanceBetweenPoints.setSelectedItem("0"); if (numberOfPointsI == 0) { dotsSide.setEnabled(false); } else if (numberOfPointsI == 1) { dotsSide.setEnabled(true); } } else { if (oldSelectedDistance != null) { distanceBetweenPoints.setSelectedItem(oldSelectedDistance); oldSelectedDistance = null; } distanceBetweenPoints.setEnabled(true); distanceToFrame.setEnabled(true); dotsSide.setEnabled(true); double pointsByLines = Math.sqrt(numberOfPointsI); side = 2d * distanceToFrameI + (pointsByLines - 1) * distanceBetweenPointsI; } } catch (RuntimeException e) { logger.error("Error calculating area of the plot", e); } DecimalFormat df = new DecimalFormat("###.##"); return df.format(side * side / 10000d); }
Example 20
Source File: KeySelectionPanel.java From nextreports-designer with Apache License 2.0 | 4 votes |
public KeySelectionPanel(boolean showValueField) { this.showValueField = showValueField; keysCombo = new JComboBox(); keysCombo.setEditable(true); AutoCompleteDecorator.decorate(keysCombo); keysCombo.setMinimumSize(dim); keysCombo.setPreferredSize(dim); if (showValueField) { keysCombo.setEnabled(false); } List<String> keys = NextReportsUtil.getReportKeys(); for (String key : keys) { keysCombo.addItem(key); } valueField = new JTextField(); valueField.setMinimumSize(dim); valueField.setPreferredSize(dim); allCheck = new JCheckBox(I18NSupport.getString("languages.keys.selection.key.all")); setLayout(new GridBagLayout()); add(new JLabel(I18NSupport.getString("languages.keys.selection.key")), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); add(keysCombo, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0)); if (showValueField) { add(new JLabel(I18NSupport.getString("languages.keys.selection.value")), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); add(valueField, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 5), 0, 0)); } else { add(allCheck, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); } }