Java 类javax.swing.ComboBoxModel 实例源码

项目:incubator-netbeans    文件:JSEApplicationClassChooser.java   
private void updatePackages() {
    final Object item = comboBoxSourceRoot.getSelectedItem();
    if (!(item instanceof SourceGroupSupport.SourceGroupProxy)) {
        return;
    }
    WAIT_MODEL.setSelectedItem(comboBoxPackage.getEditor().getItem());
    comboBoxPackage.setModel(WAIT_MODEL);

    if (updatePackagesTask != null) {
        updatePackagesTask.cancel();
    }

    updatePackagesTask = new RequestProcessor("ComboUpdatePackages").post(new Runnable() { // NOI18N
        @Override
        public void run() {
            final ComboBoxModel model = ((SourceGroupSupport.SourceGroupProxy) item).getPackagesComboBoxModel();
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    model.setSelectedItem(comboBoxPackage.getEditor().getItem());
                    comboBoxPackage.setModel(model);
                }
            });
        }
    });
}
项目:incubator-netbeans    文件:ConfigureFXMLControllerPanelVisual.java   
private void updatePackages() {
    final Object item = createdLocationComboBox.getSelectedItem();
    if (!(item instanceof SourceGroupSupport.SourceGroupProxy)) {
        return;
    }
    WAIT_MODEL.setSelectedItem(createdPackageComboBox.getEditor().getItem());
    createdPackageComboBox.setModel(WAIT_MODEL);

    if (updatePackagesTask != null) {
        updatePackagesTask.cancel();
    }

    updatePackagesTask = new RequestProcessor("ComboUpdatePackages").post(new Runnable() { // NOI18N
        @Override
        public void run() {
            final ComboBoxModel model = ((SourceGroupSupport.SourceGroupProxy) item).getPackagesComboBoxModel();
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    model.setSelectedItem(createdPackageComboBox.getEditor().getItem());
                    createdPackageComboBox.setModel(model);
                }
            });
        }
    });
}
项目:incubator-netbeans    文件:ConfigureFXMLCSSPanelVisual.java   
private void updatePackages() {
    final Object item = createdLocationComboBox.getSelectedItem();
    if (!(item instanceof SourceGroupSupport.SourceGroupProxy)) {
        return;
    }
    WAIT_MODEL.setSelectedItem(createdPackageComboBox.getEditor().getItem());
    createdPackageComboBox.setModel(WAIT_MODEL);

    if (updatePackagesTask != null) {
        updatePackagesTask.cancel();
    }

    updatePackagesTask = new RequestProcessor("ComboUpdatePackages").post(new Runnable() { // NOI18N
        @Override
        public void run() {
            final ComboBoxModel model = ((SourceGroupSupport.SourceGroupProxy) item).getPackagesComboBoxModel();
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    model.setSelectedItem(createdPackageComboBox.getEditor().getItem());
                    createdPackageComboBox.setModel(model);
                }
            });
        }
    });
}
项目:incubator-netbeans    文件:JavaTargetChooserPanelGUI.java   
private void updatePackages() {
    final Object item = rootComboBox.getSelectedItem();
    if (! (item instanceof SourceGroup)) {
        return;
    }
    WAIT_MODEL.setSelectedItem( packageComboBox.getEditor().getItem() );
    packageComboBox.setModel( WAIT_MODEL );

    if ( updatePackagesTask != null ) {
        updatePackagesTask.cancel();
    }

    updatePackagesTask = new RequestProcessor( "ComboUpdatePackages" ).post(new Runnable() {                               
        @Override
        public void run() {
            final ComboBoxModel model = PackageView.createListView((SourceGroup)item);
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run () {
                    model.setSelectedItem(packageComboBox.getEditor().getItem());
                    packageComboBox.setModel( model );
                }
            });
        }
    });                
}
项目:incubator-netbeans    文件:ScopePanel.java   
/**
 * Change the selected scope to one with the specified id. If the id does
 * not exist, nothing is changed. When the id is from a CustomScopeProvider
 * and it returns an empty scope, the preferred scope is selected.
 *
 * @see ScopeProvider.CustomScopeProvider
 *
 * @param id the id of the scope to select
 */
public void selectScopeById(@NonNull String id) {
    ComboBoxModel m = scopeCombobox.getModel();

    for (int i = 0; i < m.getSize(); i++) {
        DelegatingScopeInformation sd = (DelegatingScopeInformation) m.getElementAt(i);

        if (sd.getId().equals(id)) {
            if (sd instanceof ScopeProvider.CustomScopeProvider) {
                Scope s = sd.getScope();
                if (s != null
                        && s.getFiles().isEmpty()
                        && s.getFolders().isEmpty()
                        && s.getSourceRoots().isEmpty()) {
                    selectPreferredScope();
                    return;
                }
            }
            scopeCombobox.setSelectedItem(sd);
            return;
        }
    }
}
项目:openjdk-jdk10    文件:JFileChooserOperator.java   
private int findFileTypeIndex(String fileType, StringComparator comparator) {
    ComboBoxModel<?> cbModel = getFileTypesCombo().getModel();
    for (int i = 0; i < cbModel.getSize(); i++) {
        if (comparator.equals(((FileFilter) cbModel.getElementAt(i)).getDescription(),
                fileType)) {
            return i;
        }
    }
    return -1;
}
项目:incubator-netbeans    文件:ActiveConfigAction.java   
private void activeConfigurationChanged(final @NullAllowed ProjectConfiguration config) {
    LOGGER.log(Level.FINER, "activeConfigurationChanged: {0}", config);
    EventQueue.invokeLater(new Runnable() {
        public @Override void run() {
            listeningToCombo = false;
            try {
                configListCombo.setSelectedIndex(-1);
                if (config != null) {
                    ComboBoxModel m = configListCombo.getModel();
                    for (int i = 0; i < m.getSize(); i++) {
                        if (config.equals(m.getElementAt(i))) {
                            configListCombo.setSelectedIndex(i);
                            break;
                        }
                    }
                }
            } finally {
                listeningToCombo = true;
            }
        }
    });
}
项目:incubator-netbeans    文件:JAXBBindingInfoPnl.java   
public List<String> getBindingFiles(){
    if (this.chkbxUseBindingFile.isSelected()){
        List<String> files = new ArrayList<String>();
        ComboBoxModel model = this.cmbBindingFiles.getModel();
        int i = model.getSize();

        for (int j=0; j < i; j++ ){
            files.add((String) model.getElementAt(j));
        }
        return files;
    } else {
        return null;
    }
}
项目:incubator-netbeans    文件:ETable.java   
private ComboBoxModel getSearchComboModel() {
    DefaultComboBoxModel result = new DefaultComboBoxModel();
    for (Enumeration en = getColumnModel().getColumns(); en.hasMoreElements(); ) {
        Object column = en.nextElement();
        if (column instanceof ETableColumn) {
            ETableColumn etc = (ETableColumn)column;
            Object value = etc.getHeaderValue();
            String valueString = "";
            if (value != null) {
                valueString = value.toString();
            }
            valueString = getColumnDisplayName(valueString);
            result.addElement(valueString);
        }
    }
    return result;
}
项目:incubator-netbeans    文件:ShowEffPomDiffPanel.java   
/**
 * Creates new form ShowEffPomDiffPanel
 */
public ShowEffPomDiffPanel(ProjectConfigurationProvider<MavenConfiguration> configs) {
    initComponents();
    ComboBoxModel<MavenConfiguration> model = new DefaultComboBoxModel<MavenConfiguration>(configs.getConfigurations().toArray(new MavenConfiguration[0]));
    comConfiguration.setModel(model);
    comConfiguration.setEditable(false);
    comConfiguration.setRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            return super.getListCellRendererComponent(list, ((ProjectConfiguration)value).getDisplayName(), index, isSelected, cellHasFocus);
        }
    });
    comConfiguration.setSelectedItem(configs.getActiveConfiguration());
    enableFields();
    epProperties.setContentType("text/x-properties");
}
项目:incubator-netbeans    文件:FindUsagesDialogOperator.java   
/**
 * Select the scope
 *
 * @param projectName The name of project or null if find should be
 * performed on all projects
 */
public void setScope(String projectName) {
    JComboBoxOperator scopeOperator = getScope();
    String select_item;
    if (projectName == null) {
        select_item = Bundle.getStringTrimmed("org.netbeans.modules.refactoring.java.ui.scope.Bundle", "LBL_AllProjects");
    } else {
        select_item = projectName;
    }

    ComboBoxModel model = scopeOperator.getModel();
    int index = -1;
    String dn;
    for (int i = 0; i < model.getSize()-1; i++) { /// -1 ... it's custom and it fails
        dn = ((org.netbeans.modules.refactoring.spi.impl.DelegatingScopeProvider) model.getElementAt(i)).getDisplayName();
        if (dn.indexOf(select_item) != -1) {
            index = i;
        }
    }
    scopeOperator.selectItem(index);
}
项目:incubator-netbeans    文件:AddPropertyPanel.java   
private int findMatchingComboItem() {
    int index = typeComboBox.getSelectedIndex();
    if (index >= 0) {
        return index;
    }
    String orig = typeComboBox.getSelectedItem().toString();
    String s = orig;
    int last = s.indexOf("<");
    if (last > -1) {
        s = s.substring(0, last);
    }
    ComboBoxModel mdl = typeComboBox.getModel();
    for (int i = 0; i < mdl.getSize(); i++) {
        String t = mdl.getElementAt(i).toString();
        if (t.equals(s) ||
            (t.startsWith(s) && t.length() > last && t.charAt(last) == orig.charAt(last))) {
            return i;
        }
    }
    return -1;
}
项目:incubator-netbeans    文件:JShellOptionsPanel.java   
/**
 * Creates new form JShellOptionsPanel
 */
public JShellOptionsPanel(JShellOptionsController ctrl) {
    this.ctrl = ctrl;
    options = ShellOptions.get();

    initComponents();

    ComboBoxModel platforms = PlatformUiSupport.createPlatformComboBoxModel(null,
            Collections.singletonList(new PlatformFilter() {
                @Override
                public boolean accept(JavaPlatform platform) {
                    return options.accepts(platform);
                }
        }));
    cbPlatform.setModel(platforms);
}
项目:incubator-netbeans    文件:SettingsPanel.java   
/**
 * Selects a given template.
 *
 * @param  templatePath  path of the template which should be selected;
 *                       may be <code>null</code> - then no item is selected
 */
void selectTemplate(String templatePath) {
    if (templatePath == null) {
        return;
    }

    ComboBoxModel model = cboTemplate.getModel();
    int itemsCount = model.getSize();

    if (itemsCount == 0) {
        return;
    }

    for (int i = 0; i < itemsCount; i++) {
        NamedObject namedObj = (NamedObject) model.getElementAt(i);
        FileObject template = (FileObject) namedObj.object;
        if (template.getPath().equals(templatePath)) {
            cboTemplate.setSelectedIndex(i);
            return;
        }
    }
}
项目:incubator-netbeans    文件:DebuggingViewComponent.java   
void updateSessionsComboBox() {
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            sessionComboBox.removeActionListener(sessionsComboListener);
            sessionComboBox.removePopupMenuListener(sessionsComboListener);
            ComboBoxModel model = sessionComboBox.getModel();
            sessionComboBox.removeAllItems();
            DebuggerManager dm = DebuggerManager.getDebuggerManager();
            Session[] sessions = dm.getSessions();
            for (int x = 0; x < sessions.length; x++) {
                if (isDebuggingSession(sessions[x])) {
                    sessionComboBox.addItem(new SessionItem(sessions[x]));
                }
            }
            if (model.getSize() == 0) {
                sessionComboBox.addItem(new SessionItem(null));
            }
            sessionComboBox.setSelectedItem(new SessionItem(dm.getCurrentSession()));
            sessionComboBox.setVisible(model.getSize() > 1);
            sessionComboBox.addActionListener(sessionsComboListener);
            sessionComboBox.addPopupMenuListener(sessionsComboListener);
        }
    });
}
项目:incubator-netbeans    文件:IssuePanel.java   
private boolean selectInCombo(JComboBox combo, Object value, boolean forceInModel) {
    if (value == null) {
        return false;
    }
    if (!value.equals(combo.getSelectedItem())) {
        combo.setSelectedItem(value);
    } 
    if (forceInModel && !value.equals("") && !value.equals(combo.getSelectedItem())) { // NOI18N
        // Reload of server attributes is needed - workarounding it
        ComboBoxModel model = combo.getModel();
        if (model instanceof DefaultComboBoxModel) {
            ((DefaultComboBoxModel)model).insertElementAt(value, 0);
            combo.setSelectedIndex(0);
        }
    }
    return value.equals(combo.getSelectedItem());
}
项目:incubator-netbeans    文件:FixImportsTest.java   
/**
 * Complex fix imports test.
 */
public void testFixImportsComplex() {
    // test fix imports on List
    EditorOperator editor = new EditorOperator(TEST_CLASS_NAME);
    editor.insert("List l = new List();\n", 51, 1);

    Utilities.takeANap(100);

    // invoke fix imports
    MainWindowOperator.getDefault().pushKey(KeyEvent.VK_I,
                KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK);        
    FixAllImports fio = new FixAllImports();

    JComboBoxOperator cbo = fio.cbo(0);
    ComboBoxModel cbm = cbo.getModel();                
    fio.ok();
    // wait for fix imports
    for (int i=0; i<10; i++) {
        Utilities.takeANap(1000);
        if (editor.getText().contains("import java.util.List;")) break;
        //System.out.println(MainWindowOperator.getDefault().getStatusText());
    }
    ref(editor.getText());
    compareReferenceFiles();
    editor.close(false);
}
项目:incubator-netbeans    文件:ExtractInlinedStylePanel.java   
private ComboBoxModel createEmbeddedCssSectionsModel() {
    List<OffsetRange> ranges = context.getExistingEmbeddedCssSections();
    EmbeddedSectionItem[] values = new EmbeddedSectionItem[ranges.size() + 1];

    //new embedded section item
    values[0] = new CreateNewEmbeddedSectionItem();

    //existing sections
    for (int i = 0; i < values.length - 1; i++) {
        OffsetRange astRange = ranges.get(i);
        //recompute to document offset range
        OffsetRange range = context.getDocumentRange(astRange);
        values[i + 1] = new EmbeddedSectionItem(range,
                getRenderStringFromOffsetRange(range));
    }

    return new DefaultComboBoxModel(values);
}
项目:incubator-netbeans    文件:WizardUtils.java   
/**
 * Returns {@link ComboBoxModel} containing {@link LayerItemPresenter}s
 * wrapping all folders under the given <code>sfsRoot</code>.
 *
 * @param excludeAttrs {@link Map} of pairs String - Object used to filter
 *                     out folders which have one or more attribute(key)
 *                     with a corresponding value.
 */
public static ComboBoxModel createLayerPresenterComboModel(
        final Project project, final String sfsRoot, final Map<String,Object> excludeAttrs) {
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    try {
        FileSystem sfs = project.getLookup().lookup(NbModuleProvider.class).getEffectiveSystemFilesystem();
        FileObject root = sfs.getRoot().getFileObject(sfsRoot);
        if (root != null) {
            SortedSet<LayerItemPresenter> presenters = new TreeSet<LayerItemPresenter>();
            for (FileObject subFolder : getFolders(root, excludeAttrs)) {
                presenters.add(new LayerItemPresenter(subFolder, root));
            }
            for (LayerItemPresenter presenter : presenters) {
                model.addElement(presenter);
            }
        }
    } catch (IOException exc) {
        Logger.getLogger(UIUtil.class.getName()).log(Level.INFO, "Failed to create model of " + sfsRoot, exc);
    }
    return model;
}
项目:rapidminer    文件:DataEditor.java   
public ValueTypeCellEditor(final int valueType) {
    super(new JComboBox());
    ComboBoxModel model = new DefaultComboBoxModel() {

        private static final long serialVersionUID = 914764579359633239L;

        private String[] valueTypes = new String[VALUE_TYPE_OPTIONS[valueType].length];
        {
            for (int i = 0; i < VALUE_TYPE_OPTIONS[valueType].length; i++) {
                valueTypes[i] = Ontology.ATTRIBUTE_VALUE_TYPE.mapIndex(VALUE_TYPE_OPTIONS[valueType][i]);
            }
        }

        @Override
        public Object getElementAt(int index) {
            return valueTypes[index];
        }

        @Override
        public int getSize() {
            return valueTypes.length;
        }
    };
    ((JComboBox) super.getComponent()).setEnabled(editValueTypes);
    ((JComboBox) super.getComponent()).setModel(model);
}
项目:rapidminer    文件:AutoCompletionComboBox.java   
public AutoCompletionComboBox(boolean caseSensitive, int preferredWidth, int preferredHeight, boolean wide,
        ComboBoxModel model) {
    super(preferredWidth, preferredHeight, wide, model);

    this.caseSensitive = caseSensitive;

    setEditable(true);
    setEditor(getEditor());

    addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            setSelectedItem(((JTextField) getEditor().getEditorComponent()).getText());
            actionPerformed(new ActionEvent(this, 0, "editingStopped"));
        }
    });
}
项目:incubator-netbeans    文件:JavaFXProjectUtils.java   
public static ComboBoxModel createPlatformComboBoxModel() {
    return new PlatformsComboBoxModel(PlatformUiSupport.createPlatformComboBoxModel(JavaFXPlatformUtils.DEFAULT_PLATFORM,  // NOI18N
            Arrays.<PlatformFilter>asList(new PlatformFilter() {
                @Override
                public boolean accept(JavaPlatform platform) {
                    return JavaFXPlatformUtils.isJavaFXEnabled(platform);
                }                    
            })));
}
项目:incubator-netbeans    文件:SourceGroupSupport.java   
public ComboBoxModel getPackagesComboBoxModel() {
    if(sourceGroup != null) {
        return PackageView.createListView(sourceGroup);
    }
    if(packageProxy != null) {
        return new DefaultComboBoxModel(packageProxy.toArray(new String[0]));
    }
    return null;
}
项目:incubator-netbeans    文件:SourceGroupSupport.java   
public static ComboBoxModel getWaitModel() {
    return new DefaultComboBoxModel(
            new String[]{
                NbBundle.getMessage(SourceGroupSupport.class,
                    "LBL_ConfigureFXMLPanel_PackageName_PleaseWait") // NOI18N
            });
}
项目:incubator-netbeans    文件:DBSchemaUISupport.java   
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    Object displayName = null;
    ComboBoxModel model = comboBox.getModel();

    if (model instanceof DBSchemaModel && value instanceof FileObject) {
        displayName = ((DBSchemaModel)model).dbschemaFileList.getDisplayName((FileObject)value);
    } else {
        displayName = value;
    }

    return super.getListCellRendererComponent(list, displayName, index, isSelected, cellHasFocus);
}
项目:incubator-netbeans    文件:EntityClassesPanel.java   
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);
    }
}
项目:AntIDE    文件:PackageBrowser.java   
final public boolean showUserPackage(){
  ComboBoxModel m = libraryCombo.getModel();
  for(int i=0; i<m.getSize(); i++){
    if(((String)m.getElementAt(i)).equals("User Packages")){
      libraryCombo.setSelectedIndex(i);
      return true;
    }
  }
  return false;
}
项目:incubator-netbeans    文件:JpaControllerSetupPanelVisual.java   
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);
}
项目:incubator-netbeans    文件:PersistenceProviderComboboxHelper.java   
/**
 * Gets the provider representing the default provider from
 * the given <code>providers</code>.
 * @param providers the providers. if the default provider is supported,
 * it has to be the first element in the model.
 * @return the default provider or null if is not supported.
 */ 
private Provider getDefaultProvider(ComboBoxModel providers){
    if (!providerSupplier.supportsDefaultProvider()){
        return null;
    }
    if (providers.getElementAt(0) instanceof Provider){
        return (Provider) providers.getElementAt(0);
    }
    return null;
}
项目:incubator-netbeans    文件:SpellcheckerOptionsPanel.java   
private ComboBoxModel getLocaleModel() {
    DefaultComboBoxModel dlm = new DefaultComboBoxModel();
    List<Locale> locales = new ArrayList<Locale>(Arrays.asList(Locale.getAvailableLocales()));

    Collections.sort(locales, new LocaleComparator());

    for (Locale l : locales) {
        dlm.addElement(l);
    }

    return dlm;
}
项目:incubator-netbeans    文件:ScopePanel.java   
private void selectPreferredScope() {
    ComboBoxModel m = scopeCombobox.getModel();

    for (int i = 0; i < m.getSize(); i++) {
        DelegatingScopeInformation sd = (DelegatingScopeInformation) m.getElementAt(i);

        if (sd.getPosition() >= 0) {
            scopeCombobox.setSelectedItem(sd);
            return;
        }
    }
}
项目:incubator-netbeans    文件:SearchHistoryPanel.java   
private void updateBranchFilter (String branch) {
    currentBranchFilter = ALL_BRANCHES_FILTER;
    if (branch != null && criteria.getMode() != SearchExecutor.Mode.REMOTE_IN) {
        ComboBoxModel model = cmbBranch.getModel();
        for (int i = 0; i < model.getSize(); ++i) {
            Object filter = model.getElementAt(i);
            if (filter instanceof GitBranch && branch.equals(((GitBranch) filter).getName())) {
                currentBranchFilter = filter;
                break;
            }
        }
    }
    cmbBranch.setSelectedItem(currentBranchFilter);
}
项目:incubator-netbeans    文件:SettingsPanel.java   
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") });

}
项目:incubator-netbeans    文件:KeymapPanel.java   
private void refreshProfileCombo() {
    ignoreActionEvents = true;
    String currentProfile = getMutableModel().getCurrentProfile();
    List keymaps = getMutableModel().getProfiles();
    ComboBoxModel model = new DefaultComboBoxModel(keymaps.toArray());
    currentProfile = getMutableModel().getProfileDisplayName(currentProfile);
    cbProfile.setModel(model);
    cbProfile.setSelectedItem(currentProfile);
    ignoreActionEvents = false;
}
项目:incubator-netbeans    文件:CopyDialogTest.java   
private void assertModel (Map<String, String> items, JComboBox combo, List<String> expected) {
    ComboBoxModel model = combo.getModel();
    assertEquals(expected.size() / 2, model.getSize());
    for (int i = 0; i < model.getSize(); ++i) {
        assertEquals(expected.get(i * 2), model.getElementAt(i));
        assertEquals(expected.get(i * 2 + 1), items.get((String) model.getElementAt(i)));
    }
}
项目:incubator-netbeans    文件:IndexSearch.java   
private void mirrorMRUStrings() {
    ComboBoxModel model = searchComboBox.getModel();
    int size = model.getSize();
    MRU = new Object[size];
    for (int i = 0; i < size; i++) {
        MRU[i] = model.getElementAt(i);
    }
}
项目:incubator-netbeans    文件:HibernateCodeGenerationPanel.java   
private void updatePackageComboBox() {
    SourceGroup sourceGroup = (SourceGroup) cmbLocation.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));
        }
        cmbPackage.setModel(model);
    }
}
项目:incubator-netbeans    文件:DBSchemaUISupport.java   
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    Object displayName = null;
    ComboBoxModel model = comboBox.getModel();

    if (model instanceof DBSchemaModel && value instanceof FileObject) {
        displayName = ((DBSchemaModel)model).dbschemaFileList.getDisplayName((FileObject)value);
    } else {
        displayName = value;
    }

    return super.getListCellRendererComponent(list, displayName, index, isSelected, cellHasFocus);
}
项目:incubator-netbeans    文件:JExtendedComboBox.java   
public void setModel(ComboBoxModel aModel) {
    if (!(aModel instanceof DefaultComboBoxModel)) {
        throw new RuntimeException("Only DefaultComboBoxModel is supported for this component"); //NOI18N
    }

    model = (DefaultComboBoxModel) aModel;
    super.setModel(model);
}
项目:incubator-netbeans    文件:JWSProjectProperties.java   
private static ComboBoxModel createMixedCodeModel (final PropertyEvaluator eval) {
    assert eval != null;
    final DefaultComboBoxModel model = new DefaultComboBoxModel();
    for (MixedCodeOptions option : MixedCodeOptions.values()) {
        model.addElement(option);
    }
    final String strValue = eval.getProperty(JNLP_MIXED_CODE);
    final MixedCodeOptions value = strValue == null ? null : MixedCodeOptions.fromPropertyValue(strValue);
    if (value != null) {
        model.setSelectedItem(value);
    }
    return model;
}