List of usage examples for javax.swing ComboBoxModel getElementAt
E getElementAt(int index);
From source file:org.apache.jmeter.protocol.java.config.gui.JavaConfigGui.java
/** * Check combo contains className//from ww w . jav a 2 s . c o m * @param model ComboBoxModel * @param className String class name * @return boolean */ private static boolean checkContainsClassName(ComboBoxModel<String> model, String className) { int size = model.getSize(); Set<String> set = new HashSet<>(size); for (int i = 0; i < size; i++) { set.add(model.getElementAt(i)); } return set.contains(className); }
From source file:org.apache.jmeter.visualizers.backend.BackendListenerGui.java
/** * Check combo contains className/*from w ww .j a va 2s . c o m*/ * @param model ComboBoxModel * @param className String class name * @return boolean true if model contains className */ private static boolean checkContainsClassName(ComboBoxModel<?> model, String className) { int size = model.getSize(); Set<String> set = new HashSet<>(size); for (int i = 0; i < size; i++) { set.add((String) model.getElementAt(i)); } return set.contains(className); }
From source file:org.eclipse.wb.internal.swing.model.property.editor.models.combo.ComboBoxModelPropertyEditor.java
/** * @return the items specified in value of given {@link Property}. */// www .j a v a 2 s . c om private static String[] getItems(Property property) throws Exception { Object value = property.getValue(); if (value instanceof ComboBoxModel) { List<String> items = Lists.newArrayList(); ComboBoxModel model = (ComboBoxModel) value; for (int i = 0; i < model.getSize(); i++) { Object element = model.getElementAt(i); if (element instanceof String) { items.add((String) element); } } return items.toArray(new String[items.size()]); } // no items return ArrayUtils.EMPTY_STRING_ARRAY; }
From source file:org.gcaldaemon.gui.config.MainConfig.java
public static final boolean selectItem(JComboBox combo, String value) { if (value == null || combo == null || value.length() == 0) { return false; }//from ww w . j a va 2 s . co m ComboBoxModel model = combo.getModel(); if (model != null) { int n, size = model.getSize(); n = value.indexOf(" - "); if (n != -1) { value = value.substring(n + 3); } String test; for (int i = 0; i < size; i++) { test = (String) model.getElementAt(i); if (test != null) { n = test.indexOf(" - "); if (n != -1) { test = test.substring(n + 3); } if (test.equals(value)) { combo.setSelectedIndex(i); combo.setToolTipText((String) model.getElementAt(i)); return true; } } } } if (combo.isEditable()) { combo.setSelectedItem(value); combo.setToolTipText(value); return true; } return false; }
From source file:org.netbeans.jcode.ejb.facade.SessionBeanPanel.java
@Override public void init(String _package, Project project, SourceGroup sourceGroup) { pref = ProjectUtils.getPreferences(project, SessionBeanData.class, true); if (sourceGroup != null) { packageCombo.setRenderer(PackageView.listRenderer()); ComboBoxModel model = PackageView.createListView(sourceGroup); if (model.getSize() > 0) { model.setSelectedItem(model.getElementAt(0)); }/*from w ww . ja v a2 s. c o m*/ packageCombo.setModel(model); addChangeListener(packageCombo); if (StringUtils.isBlank(_package)) { setPackage(DEFAULT_PACKAGE); } else { setPackage(_package + '.' + DEFAULT_PACKAGE); } } addChangeListener(prefixField); addChangeListener(suffixField); }
From source file:org.netbeans.jcode.ejb.facade.SessionBeanPanel.java
private void setPackage(String _package) { ComboBoxModel model = packageCombo.getModel(); for (int i = 0; i < model.getSize(); i++) { if (model.getElementAt(i).toString().equals(_package)) { model.setSelectedItem(model.getElementAt(i)); return; }//w ww.j a va 2 s . c om } ((JTextComponent) packageCombo.getEditor().getEditorComponent()).setText(_package); }
From source file:org.netbeans.jcode.mvc.controller.MVCPanel.java
@Override public void init(String _package, Project project, SourceGroup sourceGroup) { pref = ProjectUtils.getPreferences(project, MVCData.class, true); this.project = project; this.sourceGroup = sourceGroup; if (sourceGroup != null) { packageCombo.setRenderer(PackageView.listRenderer()); ComboBoxModel model = PackageView.createListView(sourceGroup); if (model.getSize() > 0) { model.setSelectedItem(model.getElementAt(0)); }// ww w. j a va 2 s . c o m packageCombo.setModel(model); addChangeListener(packageCombo); if (StringUtils.isBlank(_package)) { _package = DEFAULT_PACKAGE; } else { _package = _package + '.' + DEFAULT_PACKAGE; } setPackage(_package); } addChangeListener(prefixField); addChangeListener(suffixField); eventObserversPanel.removeAll(); for (ControllerEventType type : ControllerEventType.values()) { JCheckBox eventTypeBox = new JCheckBox(); org.openide.awt.Mnemonics.setLocalizedText(eventTypeBox, type.toString()); // NOI18N eventObserversPanel.add(eventTypeBox); eventTypeBoxs.put(eventTypeBox, type); } final RestSupport restSupport = project.getLookup().lookup(RestSupport.class); // if (restSupport != null) { // if (restSupport.isEE5() && restSupport.hasJersey1(true) // || restSupport.hasSpringSupport() && !restSupport.hasJersey2(true)) { // useJersey = true; // } // } if (restSupport != null) { ScanDialog.runWhenScanFinished(() -> { boolean configured;//restSupport.isRestSupportOn(); configured = restSupport.hasJerseyServlet(); restApplications = restSupport.getRestApplications(); if (!configured) { configured = restApplications != null && !restApplications.isEmpty(); } if (configDialog != null) { configDialog.setRestApplicationClasses(restApplications); } configurREST(configured); }, getMessage(MVCPanel.class, "MVCPanel.scanningExistingApp.text")); } }
From source file:org.netbeans.jcode.mvc.controller.MVCPanel.java
private void setPackage(String _package) { ComboBoxModel model = packageCombo.getModel(); for (int i = 0; i < model.getSize(); i++) { if (model.getElementAt(i).toString().equals(_package)) { model.setSelectedItem(model.getElementAt(i)); break; }/*from w ww . ja v a 2 s .co m*/ } ((JTextComponent) packageCombo.getEditor().getEditorComponent()).setText(_package); }
From source file:org.netbeans.jcode.rest.applicationconfig.RestConfigPanel.java
@Override public void init(String _package, Project project, SourceGroup sourceGroup) { pref = ProjectUtils.getPreferences(project, RestConfigData.class, true); if (sourceGroup != null) { packageCombo.setRenderer(PackageView.listRenderer()); ComboBoxModel model = PackageView.createListView(sourceGroup); if (model.getSize() > 0) { model.setSelectedItem(model.getElementAt(0)); }/*from w w w . j av a 2s .com*/ packageCombo.setModel(model); addChangeListener(packageCombo); if (StringUtils.isBlank(_package)) { setPackage(DEFAULT_PACKAGE); } else { setPackage(_package); } } addChangeListener(restConfigClassField); addChangeListener(restPathField); }
From source file:org.netbeans.jcode.rest.controller.RESTPanel.java
private void setPackageType(JComboBox comboBox) { comboBox.setRenderer(PackageView.listRenderer()); ComboBoxModel model = PackageView.createListView(sourceGroup); if (model.getSize() > 0) { model.setSelectedItem(model.getElementAt(0)); }//from w w w .j ava 2 s . co m comboBox.setModel(model); addChangeListener(comboBox); }