当前位置: 首页>>代码示例>>Java>>正文


Java ComboBoxModel类代码示例

本文整理汇总了Java中javax.swing.ComboBoxModel的典型用法代码示例。如果您正苦于以下问题:Java ComboBoxModel类的具体用法?Java ComboBoxModel怎么用?Java ComboBoxModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ComboBoxModel类属于javax.swing包,在下文中一共展示了ComboBoxModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updatePackages

import javax.swing.ComboBoxModel; //导入依赖的package包/类
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);
                }
            });
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:JSEApplicationClassChooser.java

示例2: updatePackages

import javax.swing.ComboBoxModel; //导入依赖的package包/类
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);
                }
            });
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ConfigureFXMLControllerPanelVisual.java

示例3: updatePackages

import javax.swing.ComboBoxModel; //导入依赖的package包/类
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 );
                }
            });
        }
    });                
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:JavaTargetChooserPanelGUI.java

示例4: selectScopeById

import javax.swing.ComboBoxModel; //导入依赖的package包/类
/**
 * 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;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:ScopePanel.java

示例5: findFileTypeIndex

import javax.swing.ComboBoxModel; //导入依赖的package包/类
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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:JFileChooserOperator.java

示例6: activeConfigurationChanged

import javax.swing.ComboBoxModel; //导入依赖的package包/类
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;
            }
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ActiveConfigAction.java

示例7: getBindingFiles

import javax.swing.ComboBoxModel; //导入依赖的package包/类
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;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:JAXBBindingInfoPnl.java

示例8: getSearchComboModel

import javax.swing.ComboBoxModel; //导入依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ETable.java

示例9: ShowEffPomDiffPanel

import javax.swing.ComboBoxModel; //导入依赖的package包/类
/**
 * 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");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ShowEffPomDiffPanel.java

示例10: setScope

import javax.swing.ComboBoxModel; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:FindUsagesDialogOperator.java

示例11: findMatchingComboItem

import javax.swing.ComboBoxModel; //导入依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:AddPropertyPanel.java

示例12: JShellOptionsPanel

import javax.swing.ComboBoxModel; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:JShellOptionsPanel.java

示例13: selectTemplate

import javax.swing.ComboBoxModel; //导入依赖的package包/类
/**
 * 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;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:SettingsPanel.java

示例14: updateSessionsComboBox

import javax.swing.ComboBoxModel; //导入依赖的package包/类
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);
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:DebuggingViewComponent.java

示例15: selectInCombo

import javax.swing.ComboBoxModel; //导入依赖的package包/类
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());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:IssuePanel.java


注:本文中的javax.swing.ComboBoxModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。