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


Java DefaultListModel.contains方法代码示例

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


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

示例1: addJarFiles

import javax.swing.DefaultListModel; //导入方法依赖的package包/类
public static int[] addJarFiles( DefaultListModel listModel, int[] indices, String filePaths[], File base, 
        String[] variables, Callback callback) {
    int lastIndex = indices == null || indices.length == 0 ? listModel.getSize() - 1 : indices[indices.length - 1];
    int[] indexes = new int[filePaths.length];
    for( int i = 0, delta = 0; i+delta < filePaths.length; ) {            
        int current = lastIndex + 1 + i;
        ClassPathSupport.Item item = ClassPathSupport.Item.create( filePaths[i], base, null, variables != null ? variables[i] : null);
        if (callback != null) {
            callback.initItem(item);
        }
        if ( !listModel.contains( item ) ) {
            listModel.add( current, item );
            indexes[delta + i] = listModel.indexOf( item );
            i++;
        }
        else {
            indexes[i + delta] = listModel.indexOf( item );
            delta++;
        }            
    }
    return indexes;

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:ClassPathUiSupport.java

示例2: addArtifacts

import javax.swing.DefaultListModel; //导入方法依赖的package包/类
public static int[] addArtifacts( DefaultListModel listModel, int[] indices, AntArtifactItem artifactItems[],
        Callback callback) {
    int lastIndex = indices == null || indices.length == 0 ? listModel.getSize() - 1 : indices[indices.length - 1];
    int[] indexes = new int[artifactItems.length];
    for( int i = 0; i < artifactItems.length; i++ ) {
        int current = lastIndex + 1 + i;
        ClassPathSupport.Item item = ClassPathSupport.Item.create( artifactItems[i].getArtifact(), artifactItems[i].getArtifactURI(), null) ;
        if (callback != null) {
            callback.initItem(item);
        }
        if ( !listModel.contains( item ) ) {
            listModel.add( current, item );
        }            
        indexes[i] = listModel.indexOf( item );
    }
    return indexes;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ClassPathUiSupport.java

示例3: jAddAllOfficesButtonAction

import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void jAddAllOfficesButtonAction(java.awt.event.ActionEvent evt) {
    DefaultListModel availableModel = (DefaultListModel) jOfficeAvailable.getModel();
    DefaultListModel selectedModel = (DefaultListModel) jOfficeSelected.getModel();

    for (int i = 0; i < availableModel.getSize(); i++) {
        QOffice officeToAdd = (QOffice) availableModel.getElementAt(i);

        if (!selectedModel.contains(officeToAdd)) {
            selectedModel.addElement(officeToAdd);
            officesToAdd.add(officeToAdd);
        }
    }

    //Clear the remove list, since we're adding all of the offices
    officesToRemove = new LinkedList<QOffice>();
}
 
开发者ID:bcgov,项目名称:sbc-qsystem,代码行数:17,代码来源:FServiceChangeDialod.java

示例4: keyStrokeChangeActionPerformed

import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void keyStrokeChangeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keyStrokeChangeActionPerformed
    KeyStroke[] keyStrokes = ShortcutEnterPanel.showDialog();
    if (keyStrokes != null && keyStrokes.length > 0) {
        String newShortcut = WizardUtils.keyStrokesToString(keyStrokes);
        DefaultListModel lm = (DefaultListModel)shortcutsList.getModel();
        if (!lm.contains(newShortcut)) {
            lm.addElement(newShortcut);
            data.setKeyStroke(WizardUtils.keyStrokesToLogicalString(keyStrokes));
            shortcutsList.setSelectedValue(newShortcut, true);
            checkValidity();
        }
    }        
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:GUIRegistrationPanel.java

示例5: updateBuildingList

import javax.swing.DefaultListModel; //导入方法依赖的package包/类
/**
 * Update the list of available buildings to build
 *
 * This method will verify whether a building can be built by
 *      checking against the following criteria:
 *       * Does the Colony meet the population limit to build?
 *       * Does the new building require a special circumstance,
 *              such as a prerequisite unit or building?
 */
private void updateBuildingList() {
    final Specification spec = getSpecification();
    final DefaultListModel<BuildableType> current
        = (DefaultListModel<BuildableType>)this.buildQueueList.getModel();
    final DefaultListModel<BuildingType> buildings
        = (DefaultListModel<BuildingType>)this.buildingList.getModel();
    buildings.clear();
    Set<BuildableType> unbuildableTypes = new HashSet<>();

    // For each building type, find out if it is buildable, and
    // reasons to not build it (and perhaps display a lock icon).
    for (BuildingType bt : spec.getBuildingTypeList()) {
        if (unbuildableTypes.contains(bt)) continue;

        // Impossible upgrade path
        if (bt.getUpgradesFrom() != null
            && unbuildableTypes.contains(bt.getUpgradesFrom())) {
            unbuildableTypes.add(bt);
            continue;
        }

        // Ignore pre-built buildings
        if (!bt.needsGoodsToBuild()) continue;
        
        // Only one building of any kind
        if (current.contains(bt) || hasBuildingType(bt)) continue;
        
        List<String> reasons = new ArrayList<>();

        // Coastal limit
        if (bt.hasAbility(Ability.COASTAL_ONLY)
            && !this.colony.getTile().isCoastland()) {
            reasons.add(Messages.message(StringTemplate
                    .template("buildQueuePanel.coastalOnly")));
        }

        // Population limit
        if (bt.getRequiredPopulation() > this.colony.getUnitCount()) {
            reasons.add(Messages.message(StringTemplate
                    .template("buildQueuePanel.populationTooSmall")
                    .addAmount("%number%", bt.getRequiredPopulation())));
        }

        // Spec limits
        for (Limit limit : transform(bt.getLimits(),
                                     l -> !l.evaluate(this.colony))) {
            reasons.add(Messages.getDescription(limit));
        }

        // Missing ability
        if (!checkAbilities(bt, reasons)) unbuildableTypes.add(bt);

        // Upgrade path is blocked
        Building colonyBuilding = this.colony.getBuilding(bt);
        BuildingType up = bt.getUpgradesFrom();
        if (up != null && !current.contains(up)
            && (colonyBuilding == null || colonyBuilding.getType() != up)) {
            reasons.add(Messages.getName(up));
        }

        lockReasons.put(bt, (reasons.isEmpty()) ? null
            : Messages.message(StringTemplate
                .template("buildQueuePanel.requires")
                .addName("%string%", join("/", reasons))));
        if (reasons.isEmpty()
            || showAllBox.isSelected()) buildings.addElement(bt);
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:78,代码来源:BuildQueuePanel.java


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