Example usage for javax.swing ComboBoxModel setSelectedItem

List of usage examples for javax.swing ComboBoxModel setSelectedItem

Introduction

In this page you can find the example usage for javax.swing ComboBoxModel setSelectedItem.

Prototype

void setSelectedItem(Object anItem);

Source Link

Document

Set the selected item.

Usage

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;
        }//  w w  w.j  ava 2 s .com
    }
    ((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   ww w . jav a  2s  . c  o m
        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 a  v a 2s . c  om
    comboBox.setModel(model);
    addChangeListener(comboBox);
}

From source file:org.netbeans.jcode.rest.controller.RESTPanel.java

private void setAppPackage(String _package) {
    ComboBoxModel model = appPackageCombo.getModel();
    for (int i = 0; i < model.getSize(); i++) {
        if (model.getElementAt(i).toString().equals(_package)) {
            model.setSelectedItem(model.getElementAt(i));
            break;
        }//from  www.j av  a 2 s  .co  m
    }
    ((JTextComponent) appPackageCombo.getEditor().getEditorComponent()).setText(_package);
}

From source file:org.netbeans.jpa.modeler.source.generator.ui.GenerateCodeDialog.java

private void populatePackageCombo() {
    if (sourceGroup != null) {
        resourcePackageCombo.setRenderer(PackageView.listRenderer());
        ComboBoxModel model = PackageView.createListView(sourceGroup);
        if (model.getSize() > 0) {
            model.setSelectedItem(model.getElementAt(0));
        }//from ww  w.  ja  v a  2  s.co m
        resourcePackageCombo.setModel(model);
    }
}

From source file:org.netbeans.jpa.modeler.source.generator.ui.GenerateCodeDialog.java

private void setPackage(String _package) {
    ComboBoxModel model = resourcePackageCombo.getModel();
    for (int i = 0; i < model.getSize(); i++) {
        if (model.getElementAt(i).toString().equals(_package)) {
            model.setSelectedItem(model.getElementAt(i));
            return;
        }/*  w  ww.jav a2 s .  c  o  m*/
    }
    ((JTextComponent) resourcePackageCombo.getEditor().getEditorComponent()).setText(_package);
}

From source file:org.zaproxy.zap.extension.quickstart.launch.LaunchPanel.java

public void postInit() {
    // Plugable browsers (like JxBrowser) can be added after this add-ons
    // options have been loaded
    String def = this.getExtQuickStart().getQuickStartParam().getLaunchDefaultBrowser();
    if (def == null || def.length() == 0) {
        // no default
        return;//from  ww w  .  j av  a 2  s .  c om
    }
    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;
        }
    }

    this.getContentPanel().add(getHudCheckbox(), LayoutHelper.getGBC(1, hudOffset, 3, 0.25D));

    PlugableHud hud = getExtQuickStart().getHudProvider();
    if (hud != null) {
        // Build up a model just with the browsers supported by the HUD
        List<ProvidedBrowserUI> hudBrowsers = new ArrayList<ProvidedBrowserUI>();
        List<String> browserIds = hud.getSupportedBrowserIds();
        for (int i = 0; i < allBrowserModel.getSize(); i++) {
            ProvidedBrowserUI browser = allBrowserModel.getElementAt(i);
            if (browserIds.contains(browser.getBrowser().getProviderId())) {
                hudBrowsers.add(browser);
            }
        }
        hudBrowserModel = new ProvidedBrowsersComboBoxModel(hudBrowsers);
        setBrowserOptions(this.getHudCheckbox().isSelected());
    }
}