當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。