javax.swing.DefaultComboBoxModel Java Examples
The following examples show how to use
javax.swing.DefaultComboBoxModel.
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: MantTaskCron.java From openprodoc with GNU Affero General Public License v3.0 | 7 votes |
private ComboBoxModel getListObjFold() { Vector VObjects=new Vector(); try { DriverGeneric Session=MainWin.getSession(); PDObjDefs Obj = new PDObjDefs(Session); Cursor CursorId = Obj.getListFold(); Record Res=Session.NextRec(CursorId); while (Res!=null) { Attribute Attr=Res.getAttr(PDObjDefs.fNAME); VObjects.add(Attr.getValue()); Res=Session.NextRec(CursorId); } Session.CloseCursor(CursorId); } catch (PDException ex) { MainWin.Message("Error"+ex.getLocalizedMessage()); } return(new DefaultComboBoxModel(VObjects)); }
Example #2
Source File: FormBuilderController.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
private void refreshFormWidgetsCombo() { JSONObject form4Name = Utilities.getForm4Name(currentSelectedFormName, currentSelectedSectionObject); JSONArray formItems = Utilities.getFormItems(form4Name); int length = formItems.length(); if (length == 0) { _loadedWidgetsCombo.setModel(new DefaultComboBoxModel<String>()); return; } String[] names = new String[length]; for( int i = 0; i < length; i++ ) { JSONObject jsonObject = formItems.getJSONObject(i); if (jsonObject.has(Utilities.TAG_KEY)) { names[i] = jsonObject.getString(Utilities.TAG_KEY).trim(); } else if (jsonObject.has(Utilities.TAG_VALUE)) { names[i] = jsonObject.getString(Utilities.TAG_VALUE).trim(); } } _loadedWidgetsCombo.setModel(new DefaultComboBoxModel<String>(names)); }
Example #3
Source File: AmazonWizardComponent.java From netbeans with Apache License 2.0 | 6 votes |
/** Creates new form AmazonWizardComponent */ public AmazonWizardComponent(AmazonWizardPanel panel, AmazonInstance ai) { this.panel = panel; initComponents(); initRegions(); jRegionComboBox.setModel(new DefaultComboBoxModel(regions.toArray())); setName(NbBundle.getBundle(AmazonWizardComponent.class).getString("LBL_Name")); // NOI18N if (ai != null) { accessKey.setText(ai.getKeyId()); secret.setText(ai.getKey()); accessKey.setEditable(false); secret.setEditable(false); jRegionComboBox.setEnabled(false); jRegionComboBox.setSelectedItem(AmazonRegion.findRegion(ai.getRegionURL())); } accessKey.getDocument().addDocumentListener(this); secret.getDocument().addDocumentListener(this); }
Example #4
Source File: BasePanel.java From netbeans with Apache License 2.0 | 6 votes |
public void run() { // build the allowed values String allowedRegEx = jcb.getActionCommand(); DefaultComboBoxModel dcbm = new DefaultComboBoxModel(); Pattern p = Pattern.compile(allowedRegEx); Set<String> keys = data.keySet(); //String pushPrefix = null; for (String k : keys) { Matcher test = p.matcher(k); if (test.matches()) { dcbm.addElement(data.get(k)); } } jcb.setModel(dcbm); jcb.setSelectedItem(value); }
Example #5
Source File: SummaryTablePanel.java From nmonvisualizer with Apache License 2.0 | 6 votes |
private void updateStatisticsComboBox() { String newName = Statistic.GRANULARITY_MAXIMUM.getName(gui.getGranularity()); @SuppressWarnings("unchecked") DefaultComboBoxModel<Object> model = (DefaultComboBoxModel<Object>) ((JComboBox<Object>) statsPanel .getComponent(1)).getModel(); boolean reselect = false; if (model.getSelectedItem() == model.getElementAt(4)) { reselect = true; } model.removeElementAt(4); model.insertElementAt(newName, 4); if (reselect) { model.setSelectedItem(newName); } }
Example #6
Source File: SetMapClientAction.java From triplea with GNU General Public License v3.0 | 6 votes |
@Override public void actionPerformed(final ActionEvent e) { if (availableGames.isEmpty()) { JOptionPane.showMessageDialog( parent, "No available games", "No available games", JOptionPane.ERROR_MESSAGE); return; } final DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>(); final JComboBox<String> combo = new JComboBox<>(model); model.addElement(""); model.addAll(availableGames); final int selectedOption = JOptionPane.showConfirmDialog( parent, combo, "Change Game To: ", JOptionPane.OK_CANCEL_OPTION); if (selectedOption != JOptionPane.OK_OPTION) { return; } final String name = (String) combo.getSelectedItem(); if (name == null || name.length() <= 1) { return; } serverStartupRemote.changeServerGameTo(name); }
Example #7
Source File: TypeChooser.java From Shuffle-Move with GNU General Public License v3.0 | 6 votes |
public void setSelectedType(PkmType type) { String toSelect = null; if (type != null) { if (shouldRebuild) { refill(); } toSelect = WordUtils.capitalizeFully(type.toString()); DefaultComboBoxModel<String> model = (DefaultComboBoxModel<String>) getModel(); if (model.getIndexOf(toSelect) == -1) { shouldRebuild = true; insertItemAt(toSelect, 0); } else { shouldRebuild = false; } } setSelectedItem(toSelect); }
Example #8
Source File: StrokeChooserPanel.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Creates a panel containing a combo-box that allows the user to select * one stroke from a list of available strokes. * * @param current the current stroke sample. * @param available an array of 'available' stroke samples. */ public StrokeChooserPanel(StrokeSample current, StrokeSample[] available) { setLayout(new BorderLayout()); // we've changed the behaviour here to populate the combo box // with Stroke objects directly - ideally we'd change the signature // of the constructor too...maybe later. DefaultComboBoxModel model = new DefaultComboBoxModel(); for (int i = 0; i < available.length; i++) { model.addElement(available[i].getStroke()); } this.selector = new JComboBox(model); this.selector.setSelectedItem(current.getStroke()); this.selector.setRenderer(new StrokeSample(null)); add(this.selector); // Changes due to focus problems!! DZ this.selector.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent evt) { getSelector().transferFocus(); } }); }
Example #9
Source File: FormUtils.java From jdal with Apache License 2.0 | 6 votes |
/** * Add a link on primary and dependent JComboBoxes by property name. * When selection changes on primary use propertyName to get a Collection and fill dependent JComboBox with it * @param primary JComboBox when selection changes * @param dependent JComboBox that are filled with collection * @param propertyName the property name for get the collection from primary selected item * @param addNull if true, add a null as first combobox item */ @SuppressWarnings("rawtypes") public static void link(final JComboBox primary, final JComboBox dependent, final String propertyName, final boolean addNull) { primary.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Object selected = primary.getSelectedItem(); if (selected != null) { BeanWrapper wrapper = PropertyAccessorFactory.forBeanPropertyAccess(selected); if (wrapper.isWritableProperty(propertyName)) { Collection collection = (Collection) wrapper.getPropertyValue(propertyName); Vector<Object> vector = new Vector<Object>(collection); if (addNull) vector.add(0, null); DefaultComboBoxModel model = new DefaultComboBoxModel(vector); dependent.setModel(model); } else { log.error("Can't write on propety '" + propertyName + "' of class: '" + selected.getClass() + "'"); } } } }); }
Example #10
Source File: DialogImportExtFolders.java From openprodoc with GNU Affero General Public License v3.0 | 6 votes |
/** * Obtains a list of clases of type Doc allowed to the user * @return a DefaultComboModel with names of classes of Docs */ private DefaultComboBoxModel getComboModelDoc() { Vector VObjects=new Vector(); try { DriverGeneric Session=MainWin.getSession(); PDObjDefs Obj = new PDObjDefs(Session); Cursor CursorId = Obj.getListDocs(); Record Res=Session.NextRec(CursorId); while (Res!=null) { Attribute Attr=Res.getAttr(PDObjDefs.fNAME); VObjects.add(Attr.getValue()); Res=Session.NextRec(CursorId); } Session.CloseCursor(CursorId); } catch (PDException ex) { MainWin.Message(ex.getLocalizedMessage()); } return(new DefaultComboBoxModel(VObjects)); }
Example #11
Source File: JFXRunPanel.java From netbeans with Apache License 2.0 | 6 votes |
private java.util.List<PlatformKey> updatePlatformsList() { final java.util.List<PlatformKey> platformList = new ArrayList<PlatformKey>(); final SpecificationVersion targetLevel = new SpecificationVersion("1.8"); final SourceLevelQuery.Profile targetProfile = SourceLevelQuery.Profile.COMPACT1; if (targetLevel != null && targetProfile != null) { for (J2SERuntimePlatformProvider rpt : project.getLookup().lookupAll(J2SERuntimePlatformProvider.class)) { for (JavaPlatform jp : rpt.getPlatformType(targetLevel, targetProfile)) { platformList.add(PlatformKey.create(jp)); } } Collections.sort(platformList); } platformList.add(0, PlatformKey.createDefault()); final DefaultComboBoxModel<PlatformKey> model = new DefaultComboBoxModel<PlatformKey>(platformList.toArray(new PlatformKey[0])); comboBoxRuntimePlatform.setModel(model); return platformList; }
Example #12
Source File: KnownSaneOptions.java From swingsane with Apache License 2.0 | 6 votes |
public static ComboBoxModel<String> getPageSizeModel(Scanner scanner) { DefaultComboBoxModel<String> pageSizeModel = new DefaultComboBoxModel<String>(); HashMap<String, StringOption> stringOptions = scanner.getStringOptions(); StringOption stringOption = stringOptions.get(EPSON_NAME_SCAN_AREA); if (stringOption == null) { return null; } Constraints constraints = stringOption.getConstraints(); List<String> values = constraints.getStringList(); for (String value : values) { pageSizeModel.addElement(value); } if (values.size() > 0) { return pageSizeModel; } else { return null; } }
Example #13
Source File: SchemaPanel.java From netbeans with Apache License 2.0 | 6 votes |
public Component getTableCellEditorComponent(JTable table, Object obj, boolean isSelected, int row, int col) { comboBox = new JComboBox(); comboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { fireEditingStopped(); } }); DefaultComboBoxModel rootModel = new DefaultComboBoxModel(); SchemaObject o = (SchemaObject)table.getModel().getValueAt(row, SCHEMA_COL); if( !(o.toString().equals(startString))) { String[] root = o.getRootElements(); if(root != null && root.length >0) { for(int i=0; i < root.length; i++) rootModel.addElement(root[i]); } } comboBox.setModel(rootModel); return comboBox; }
Example #14
Source File: FmtCodeGeneration.java From netbeans with Apache License 2.0 | 6 votes |
private void enableInsertionPoint() { if (ipModel == null) { ipModel = insertionPointComboBox.getModel(); } Object[] values; Object toSelect = insertionPointComboBox.getSelectedItem(); if (sortMembersAlphaCheckBox.isSelected()) { if (toSelect == ipModel.getElementAt(0) || toSelect == ipModel.getElementAt(1)) { toSelect = ipModel.getElementAt(2); } values = new Object[] {ipModel.getElementAt(2), ipModel.getElementAt(3)}; } else { if (toSelect == ipModel.getElementAt(2)) { toSelect = ipModel.getElementAt(0); } values = new Object[] {ipModel.getElementAt(0), ipModel.getElementAt(1), ipModel.getElementAt(3)}; } insertionPointComboBox.setModel(new DefaultComboBoxModel(values)); insertionPointComboBox.setSelectedItem(toSelect); }
Example #15
Source File: GUIRegistrationPanel.java From netbeans with Apache License 2.0 | 6 votes |
private void createPositionModel(final JComboBox positionsCombo, final FileObject[] files, final LayerItemPresenter parent) { DefaultComboBoxModel<Position> newModel = new DefaultComboBoxModel<>(); LayerItemPresenter previous = null; for (FileObject file : files) { if (file.getNameExt().endsWith(LayerUtil.HIDDEN)) { continue; } LayerItemPresenter current = new LayerItemPresenter( file, parent.getFileObject()); newModel.addElement(createPosition(previous, current)); previous = current; } newModel.addElement(createPosition(previous, null)); positionsCombo.setModel(newModel); checkValidity(); }
Example #16
Source File: LoginDialog.java From arcusplatform with Apache License 2.0 | 6 votes |
protected void onShow() { List<OculusSession> recentSessions = ServiceLocator.getInstance(SessionController.class).listRecentSessions(); if(!lastSessions.equals(recentSessions)) { lastSessions = recentSessions; DefaultComboBoxModel<OculusSession> model = ((DefaultComboBoxModel<OculusSession>) serviceUri.getModel()); model.removeAllElements(); for(OculusSession hau: ServiceLocator.getInstance(SessionController.class).listRecentSessions()) { model.addElement(hau); } } if(username.getText().isEmpty()) { username.requestFocusInWindow(); } else { password.requestFocusInWindow(); } }
Example #17
Source File: MyEditingGraphMousePlugin.java From cloudml with GNU Lesser General Public License v3.0 | 6 votes |
public VMInstance selectDestination() { JPanel panel = new JPanel(); panel.add(new JLabel("Please make a selection:")); DefaultComboBoxModel model = new DefaultComboBoxModel(); for (ExternalComponentInstance n : dm.getComponentInstances().onlyExternals()) { model.addElement(n); } JComboBox comboBox = new JComboBox(model); panel.add(comboBox); int result = JOptionPane.showConfirmDialog(null, panel, "Destination", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); switch (result) { case JOptionPane.OK_OPTION: return ((VMInstance) comboBox.getSelectedItem()); } return null; }
Example #18
Source File: Repository.java From netbeans with Apache License 2.0 | 6 votes |
RepositoryConnection getSelectedRCIntern() { String urlString; try { urlString = getUrlString(); } catch (InterruptedException ex) { // should not happen Subversion.LOG.log(Level.SEVERE, null, ex); return null; } DefaultComboBoxModel dcbm = (DefaultComboBoxModel) repositoryPanel.urlComboBox.getModel(); int idx = dcbm.getIndexOf(urlString); if(idx > -1) { return (RepositoryConnection) dcbm.getElementAt(idx); } return getEditedRC(); }
Example #19
Source File: FunctionField.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** Populate function combo box. */ private void populateFunctionComboBox() { if (functionComboBox != null) { DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>(); model.addElement(""); // Sort function names alphabetically List<String> functionNameList = new ArrayList<>(functionNameMap.keySet()); java.util.Collections.sort(functionNameList); for (String name : functionNameList) { model.addElement(name); } functionComboBox.setModel(model); } }
Example #20
Source File: CrewEditor.java From mars-sim with GNU General Public License v3.0 | 6 votes |
public DefaultComboBoxModel<String> setUpJobCBModel() { List<String> jobs = JobType.getList(); jobs.remove(POLITICIAN); Collections.sort(jobs); DefaultComboBoxModel<String> m = new DefaultComboBoxModel<String>(); Iterator<String> j = jobs.iterator(); while (j.hasNext()) { String s = j.next(); m.addElement(s); } return m; }
Example #21
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 #22
Source File: RangeEditorDialog.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
RangeEditorDialog(Window window, Model model) { super(window, "New Range Mask", ModalDialog.ID_OK_CANCEL | ModalDialog.ID_HELP, "rangeEditor"); this.model = model; container = PropertyContainer.createObjectBacked(this.model); getJDialog().setResizable(false); rasterModel = new DefaultComboBoxModel(this.model.rasterNames); setContent(createUI()); }
Example #23
Source File: HashtableKeyValueEditor.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
/** Creates new form HashtableKeyValueEditor */ public HashtableKeyValueEditor(EditableResources res, String keyString, Object value) { initComponents(); this.res = res; ResourceEditorView.initImagesComboBox(imageValue, res, true, false); String[] arr = new String[res.getUIResourceNames().length]; System.arraycopy(res.getUIResourceNames(), 0, arr, 0, arr.length); Arrays.sort(arr); navigationCombo.setModel(new DefaultComboBoxModel(arr)); if(keyString != null) { key.setText(keyString); if(value instanceof String) { if(keyString.equals("$navigation")) { isNavigation.setSelected(true); stringValue.setEnabled(false); key.setEnabled(false); navigationCombo.setEnabled(true); navigationCombo.setSelectedItem(value); } if(value.equals("true") || value.equals("false")) { booleanValue.setSelected(true); booleanValue.setEnabled(true); isBoolean.setSelected(true); stringValue.setEnabled(false); } else { stringValue.setText((String)value); } return; } if(value instanceof com.codename1.ui.Image) { isImage.setSelected(true); imageValue.setSelectedItem(res.findId(value)); stringValue.setEnabled(false); imageValue.setEnabled(true); return; } } }
Example #24
Source File: OnSaveTabPanel.java From netbeans with Apache License 2.0 | 5 votes |
public void setSelector(OnSaveTabSelector selector) { if (selector == null) { storedMimeType = (String)cboLanguage.getSelectedItem(); } if (this.selector != null) { this.selector.removePropertyChangeListener(weakListener); } this.selector = selector; if (this.selector != null) { this.weakListener = WeakListeners.propertyChange(this, this.selector); this.selector.addPropertyChangeListener(weakListener); DefaultComboBoxModel model = new DefaultComboBoxModel(); String preSelectMimeType = null; for (String mimeType : this.selector.getMimeTypes()) { model.addElement(mimeType); if (mimeType.equals(storedMimeType)) { preSelectMimeType = mimeType; } } cboLanguage.setModel(model); // Pre-select a language if (preSelectMimeType == null) { JTextComponent pane = EditorRegistry.lastFocusedComponent(); preSelectMimeType = pane != null ? (String)pane.getDocument().getProperty("mimeType") : ""; // NOI18N } cboLanguage.setSelectedItem(preSelectMimeType); if (!preSelectMimeType.equals(cboLanguage.getSelectedItem())) { cboLanguage.setSelectedIndex(0); } } else { cboLanguage.setModel(new DefaultComboBoxModel()); } }
Example #25
Source File: ModernComboCheckBox.java From nanoleaf-desktop with MIT License | 5 votes |
private String[] modelToArray(DefaultComboBoxModel<T> model) { String[] items = new String[model.getSize()]; for (int i = 0; i < model.getSize(); i++) { items[i] = (String)model.getElementAt(i); } return items; }
Example #26
Source File: SettingsPanel.java From netbeans with Apache License 2.0 | 5 votes |
private ComboBoxModel createComboModel() { return new DefaultComboBoxModel( new String[] { org.openide.util.NbBundle.getMessage(SettingsPanel.class, "FREQ_weekly"), org.openide.util.NbBundle.getMessage(SettingsPanel.class, "FREQ_Daily"), org.openide.util.NbBundle.getMessage(SettingsPanel.class, "FREQ_Always"), org.openide.util.NbBundle.getMessage(SettingsPanel.class, "FREQ_Never") }); }
Example #27
Source File: PresetAnalyzerPanelProvider.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public void setPresetAnalyzers(Collection<Class<? extends Analyzer>> presetAnalyzers) { String[] analyzerNames = presetAnalyzers.stream().map(Class::getName).toArray(String[]::new); ComboBoxModel<String> model = new DefaultComboBoxModel<>(analyzerNames); analyzersCB.setModel(model); analyzersCB.setEnabled(true); }
Example #28
Source File: TemplateChooserPanelGUI.java From netbeans with Apache License 2.0 | 5 votes |
private void selectProject (@NullAllowed Project p) { if (p != null) { DefaultComboBoxModel projectsModel = (DefaultComboBoxModel) projectsComboBox.getModel (); if ( projectsModel.getIndexOf( p ) == -1 ) { projectsModel.insertElementAt( p, 0 ); } projectsComboBox.setSelectedItem( p ); } else { projectsComboBox.setSelectedItem(null); } }
Example #29
Source File: SourceGroupSupport.java From netbeans with Apache License 2.0 | 5 votes |
public ComboBoxModel getPackagesComboBoxModel() { if(sourceGroup != null) { return PackageView.createListView(sourceGroup); } if(packageProxy != null) { return new DefaultComboBoxModel(packageProxy.toArray(new String[0])); } return null; }
Example #30
Source File: DiffToRevision.java From netbeans with Apache License 2.0 | 5 votes |
private void initializeCombo () { DefaultComboBoxModel model = new DefaultComboBoxModel(kinds); for (DiffToRevisionKind kind : kinds) { panel.panelDiffKind.add(kind.getPanel(), kind.getId()); kind.addPropertyChangeListener(this); } panel.cmbDiffKind.setModel(model); panel.cmbDiffKind.setRenderer(new DiffKindRenderer()); panel.cmbDiffKind.setSelectedIndex(1); }