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


Java DefaultListModel.indexOf方法代码示例

本文整理汇总了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;

}
 
开发者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: 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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:FolderList.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:CodeCompletionPanel.java


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