Java Code Examples for javax.swing.ComboBoxModel#setSelectedItem()

The following examples show how to use javax.swing.ComboBoxModel#setSelectedItem() . 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: SampleRepositoryConfigPanel.java    From jeddict with Apache License 2.0 6 votes vote down vote up
@Override
public void init(String _package, Project project, SourceGroup sourceGroup) {
    pref = ProjectUtils.getPreferences(project, SampleRepositoryConfigData.class, true);
    if (sourceGroup != null) {
        packageCombo.setRenderer(PackageView.listRenderer());
        ComboBoxModel model = PackageView.createListView(sourceGroup);
        if (model.getSize() > 0) {
            model.setSelectedItem(model.getElementAt(0));
        }
        packageCombo.setModel(model);
        addChangeListener(packageCombo);
        if (StringUtils.isBlank(_package)) {
            setPackage(DEFAULT_PACKAGE);
        } else {
            setPackage(_package + '.' + DEFAULT_PACKAGE);
        }
    }
    addChangeListener(prefixField);
    addChangeListener(suffixField);
}
 
Example 2
Source File: AjaxSpiderExplorer.java    From zap-extensions with Apache License 2.0 6 votes vote down vote up
public void optionsLoaded(QuickStartParam quickStartParam) {
    getSelectCheckBox().setSelected(quickStartParam.isAjaxSpiderEnabled());
    String def = quickStartParam.getAjaxSpiderDefaultBrowser();
    if (def == null || def.length() == 0) {
        // no default
        return;
    }
    ComboBoxModel<ProvidedBrowserUI> model = this.getBrowserComboBox().getModel();
    for (int idx = 0; idx < model.getSize(); idx++) {
        ProvidedBrowserUI el = model.getElementAt(idx);
        if (el.getName().equals(def)) {
            model.setSelectedItem(el);
            break;
        }
    }
}
 
Example 3
Source File: DBScriptPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void updatePackageComboBox() {
    SourceGroup sourceGroup = (SourceGroup) locationComboBox.getSelectedItem();
    if (sourceGroup != null) {
        ComboBoxModel model = PackageView.createListView(sourceGroup);
        if (model.getSelectedItem() != null && model.getSelectedItem().toString().startsWith("META-INF")
                && model.getSize() > 1) { // NOI18N
            model.setSelectedItem(model.getElementAt(1));
        }
        packageComboBox.setModel(model);
    }
}
 
Example 4
Source File: ClassSetupPanelVisual.java    From jeddict with Apache License 2.0 5 votes vote down vote up
private void updateSourceGroupPackages() {
    SourceGroup sourceGroup = (SourceGroup) locationComboBox.getSelectedItem();
    ComboBoxModel model = PackageView.createListView(sourceGroup);
    if (model.getSelectedItem() != null && model.getSelectedItem().toString().startsWith("META-INF")
            && model.getSize() > 1) { // NOI18N
        model.setSelectedItem(model.getElementAt(1));
    }
    packageComboBox.setModel(model);
}
 
Example 5
Source File: EntityClassesConfigurationPanel.java    From jeddict with Apache License 2.0 5 votes vote down vote up
private void updatePackageComboBox() {
    SourceGroup sourceGroup = (SourceGroup) locationComboBox.getSelectedItem();
    if (sourceGroup != null) {
        ComboBoxModel model = PackageView.createListView(sourceGroup);
        if (model.getSelectedItem() != null && model.getSelectedItem().toString().startsWith("META-INF")
                && model.getSize() > 1) { // NOI18N
            model.setSelectedItem(model.getElementAt(1));
        }
        packageComboBox.setModel(model);
    }
}
 
Example 6
Source File: DocSetupPanelVisual.java    From jeddict with Apache License 2.0 5 votes vote down vote up
private void updateSourceGroupPackages() {
    SourceGroup sourceGroup = (SourceGroup) locationComboBox.getSelectedItem();
    ComboBoxModel model = PackageView.createListView(sourceGroup);
    if (model.getSelectedItem() != null && model.getSelectedItem().toString().startsWith("META-INF")
            && model.getSize() > 1) { // NOI18N
        model.setSelectedItem(model.getElementAt(1));
    }
    packageComboBox.setModel(model);
}
 
Example 7
Source File: GenerateCodeDialog.java    From jeddict with Apache License 2.0 5 votes vote down vote up
private void populatePackageCombo(JComboBox packageCombo, ProjectInfo projectInfo) {
    if (projectInfo.getSourceGroup() != null) {
        packageCombo.setRenderer(PackageView.listRenderer());
        ComboBoxModel model = PackageView.createListView(projectInfo.getSourceGroup());
        if (model.getSize() > 0) {
            model.setSelectedItem(model.getElementAt(0));
        }
        packageCombo.setModel(model);
    }
}
 
Example 8
Source File: SampleRepositoryConfigPanel.java    From jeddict with Apache License 2.0 5 votes vote down vote up
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;
        }
    }
    ((JTextComponent) packageCombo.getEditor().getEditorComponent()).setText(_package);
}
 
Example 9
Source File: PrintPreviewDialog.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void done()
{
	try
	{
		ComboBoxModel<Object> model = new DefaultComboBoxModel<>(get());
		model.setSelectedItem(null);
		sheetBox.setModel(model);
	}
	catch (InterruptedException | ExecutionException ex)
	{
		Logging.errorPrint("could not load sheets", ex);
	}
}
 
Example 10
Source File: EjbFacadeVisualPanel2.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void updateSourceGroupPackages() {
    SourceGroup sourceGroup = (SourceGroup)locationComboBox.getSelectedItem();
    if (sourceGroup != null) {
        ComboBoxModel model = PackageView.createListView(sourceGroup);
        if (model.getSelectedItem()!= null && model.getSelectedItem().toString().startsWith("META-INF") //NOI18N
                && model.getSize() > 1) { // NOI18N
            model.setSelectedItem(model.getElementAt(1));
        }
        packageComboBox.setModel(model);
    }
}
 
Example 11
Source File: PersistenceClientSetupPanelVisual.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void updateSourceGroupPackages() {
    SourceGroup sourceGroup = (SourceGroup)locationComboBox.getSelectedItem();
    JComboBox[] combos = {jpaPackageComboBox, jsfPackageComboBox};
    for (JComboBox combo : combos) {
        ComboBoxModel model = PackageView.createListView(sourceGroup);
        if (model.getSelectedItem()!= null && model.getSelectedItem().toString().startsWith("META-INF")
                && model.getSize() > 1) { // NOI18N
            model.setSelectedItem(model.getElementAt(1));
        }
        combo.setModel(model);
    }
}
 
Example 12
Source File: SingletonSetupPanelVisual.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void updateSourceGroupPackages() {
    SourceGroup sourceGroup = getSourceGroup();
    if (sourceGroup != null) {
        ComboBoxModel model = PackageView.createListView(sourceGroup);
        if (model.getSelectedItem() != null && model.getSelectedItem().toString().startsWith("META-INF") && model.getSize() > 1) { // NOI18N

            model.setSelectedItem(model.getElementAt(1));
        }
        packageComboBox.setModel(model);
    }
}
 
Example 13
Source File: ContainerItemSetupPanelVisual.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void updateSourceGroupPackages() {
    SourceGroup sourceGroup = (SourceGroup)locationComboBox.getSelectedItem();
    if (sourceGroup != null) {
        ComboBoxModel model = PackageView.createListView(sourceGroup);
        if (model.getSelectedItem()!= null && model.getSelectedItem().toString().startsWith("META-INF")
                && model.getSize() > 1) { // NOI18N
            model.setSelectedItem(model.getElementAt(1));
        }
        packageComboBox.setModel(model);
    }
}
 
Example 14
Source File: JaxRsConfigurationPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void updateSourceGroupPackages() {
    SourceGroup sg = getSourceGroup();
    if (sg != null) {
        ComboBoxModel model = PackageView.createListView(sg);
        if (model.getSelectedItem()!= null && model.getSelectedItem().toString().startsWith("META-INF")
                && model.getSize() > 1) { // NOI18N
            model.setSelectedItem(model.getElementAt(1));
        }
        String oldValue = ((JTextComponent)restAppPackage.getEditor().getEditorComponent()).getText();
        restAppPackage.setModel(model);
        if (oldValue.length() > 0) {
            ((JTextComponent)restAppPackage.getEditor().getEditorComponent()).setText(oldValue);
        }
    }
}
 
Example 15
Source File: EntityResourcesSetupPanelVisual.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void updateSourceGroupPackages() {
    SourceGroup sourceGroup = (SourceGroup) locationComboBox.getSelectedItem();
    if (sourceGroup != null) {
        ComboBoxModel model = PackageView.createListView(sourceGroup);
        if (model.getSize() > 0) {
            model.setSelectedItem(model.getElementAt(0));
        }
        resourcePackageComboBox.setModel(model);
        model = PackageView.createListView(sourceGroup);
        if (model.getSize() > 0) {
            model.setSelectedItem(model.getElementAt(0));
        }
        controllerPackageComboBox.setModel(model);
    }
}
 
Example 16
Source File: LicenseHeadersPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void setGlobalLicense(String lic) {
    lic = lic != null ? lic : "default"; //NOI18N
    ComboBoxModel<GlobalItem> model = cbGlobalLicense.getModel();
    for (int i = 0; i < model.getSize(); i++) {
        GlobalItem item = model.getElementAt(i);
        if (lic.equals(item.getName())) {
            model.setSelectedItem(item);
            break;
        }
    }
}
 
Example 17
Source File: JpaControllerSetupPanelVisual.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void updateSourceGroupPackages() {
    SourceGroup sourceGroup = (SourceGroup)locationComboBox.getSelectedItem();
    ComboBoxModel model = PackageView.createListView(sourceGroup);
    if (model.getSelectedItem()!= null && model.getSelectedItem().toString().startsWith("META-INF")
            && model.getSize() > 1) { // NOI18N
        model.setSelectedItem(model.getElementAt(1));
    }
    packageComboBox.setModel(model);
}
 
Example 18
Source File: TableInternalFrame.java    From chipster with MIT License 5 votes vote down vote up
/**
 * Updates chip count combobox.
 * 
 * @param columnIndex
 */
public void updateChipCountComboBox(int columnIndex){
	int chipCount = screen.getColumnTypeManager().getChipCount();
	
	Object[] items;
	Object selectedItem = null;

	// Keep the list empty if the type of column is UNUSED
	if(screen.getColumnTypeManager().getColumnType(columnIndex).equals(ColumnType.UNUSED_LABEL)
			|| screen.getColumnTypeManager().getColumnType(columnIndex).equals(ColumnType.ANNOTATION_LABEL)
			|| screen.getColumnTypeManager().getColumnType(columnIndex).equals(ColumnType.IDENTIFIER_LABEL)){
		items = new Integer[0];
	} else {
		items = new Integer[chipCount];
		for(int chipNum = 1; chipNum <= chipCount; chipNum++){
			items[chipNum-1] = chipNum;
			if(chipNum == screen.getColumnTypeManager().getColumnChipNumber(columnIndex)){
				selectedItem = chipNum;
			}
		}
	}

	ComboBoxModel model = new DefaultComboBoxModel(items);
	model.setSelectedItem(selectedItem);
			
	table.getHeaderRenderer(columnIndex).getCombo().setModel(model);
	table.getHeaderRenderer(columnIndex).getCombo().setEnabled(model.getSize() > 0);
	table.getHeaderRenderer(columnIndex).update();
}
 
Example 19
Source File: UpdateSummaryTable.java    From bigtable-sql with Apache License 2.0 4 votes vote down vote up
private ComboBoxModel getComboBoxModel(ArtifactAction... actions) {
	ComboBoxModel result = new DefaultComboBoxModel(actions);
	result.setSelectedItem(actions[0]);
	return result;
}
 
Example 20
Source File: AutoCompletionListener.java    From jdal with Apache License 2.0 4 votes vote down vote up
/**
 * @param model
 * @param list
 */
private void addList(List<?> list) {
	ComboBoxModel model = new DefaultComboBoxModel(list.toArray());
	model.setSelectedItem(null);
	combo.setModel(model);
}