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