本文整理汇总了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;
}
示例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;
}
示例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>();
}
示例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();
}
}
}
示例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);
}
}