本文整理汇总了Java中javax.swing.DefaultListModel.indexOf方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultListModel.indexOf方法的具体用法?Java DefaultListModel.indexOf怎么用?Java DefaultListModel.indexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.DefaultListModel
的用法示例。
在下文中一共展示了DefaultListModel.indexOf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: addFiles
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void addFiles (final File[] toAddArr, final Set<? super File> invalidRoots) {
final int[] indecesToSelect = new int[toAddArr.length];
final DefaultListModel model = (DefaultListModel)this.roots.getModel();
final File[] relatedFolders = this.relatedFolderList == null ?
new File[0] : this.relatedFolderList.getFiles();
for (int i=0, index=model.size(); i<toAddArr.length; i++) {
File normalizedFile = toAddArr[i];
if (!isValidRoot(normalizedFile, relatedFolders, this.projectFolder)) {
invalidRoots.add (normalizedFile);
}
else {
int pos = model.indexOf (normalizedFile);
if (pos == -1) {
model.addElement (normalizedFile);
indecesToSelect[i] = index;
}
else {
indecesToSelect[i] = pos;
}
index++;
}
}
this.roots.setSelectedIndices(indecesToSelect);
this.firePropertyChange(PROP_FILES, null, null);
}
示例4: javaCompletionExcluderDialogOkButtonActionPerformed
import javax.swing.DefaultListModel; //导入方法依赖的package包/类
private void javaCompletionExcluderDialogOkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderDialogOkButtonActionPerformed
JList list = getSelectedExcluderList();
String text = javaCompletionExcluderDialogTextField.getText();
DefaultListModel model = (DefaultListModel) list.getModel();
int index = model.size();
if (javaExcluderEditing != null){
// if this was an "edit" rather than "add", then remove the old entry first
index = model.indexOf(javaExcluderEditing);
model.remove(index);
javaExcluderEditing = null;
}
String[] entries = text.split(","); // NOI18N
for (String entry : entries) {
// strip zero width spaces
entry = entry.replaceAll("\u200B", ""); // NOI18N
entry = entry.trim();
if (entry.length() != 0 && entry.matches(JAVA_FQN_REGEX)){
model.insertElementAt(entry, index);
index++;
}
}
updateExcluder(list);
javaCompletionExcluderDialog2.setVisible(false);
javaCompletionExcluderDialogTextField.setText(null);
}