當前位置: 首頁>>代碼示例>>Java>>正文


Java ListSelectionModel.clearSelection方法代碼示例

本文整理匯總了Java中javax.swing.ListSelectionModel.clearSelection方法的典型用法代碼示例。如果您正苦於以下問題:Java ListSelectionModel.clearSelection方法的具體用法?Java ListSelectionModel.clearSelection怎麽用?Java ListSelectionModel.clearSelection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.ListSelectionModel的用法示例。


在下文中一共展示了ListSelectionModel.clearSelection方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setTo

import javax.swing.ListSelectionModel; //導入方法依賴的package包/類
public void setTo(ListSelectionModel sm) {
    sm.clearSelection();
    sm.setSelectionMode(selectionMode);
    for (int[] itv : intervals) {
        sm.addSelectionInterval(itv[0], itv[1]);
    }
    sm.setAnchorSelectionIndex(anchor);
    sm.setLeadSelectionIndex(lead);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:OutlineView.java

示例2: setSelectedNodes

import javax.swing.ListSelectionModel; //導入方法依賴的package包/類
public final void setSelectedNodes (File[] selectedFiles) {
    Set<File> files = new HashSet<File>(Arrays.asList(selectedFiles));
    ListSelectionModel selection = table.getSelectionModel();
    selection.setValueIsAdjusting(true);
    selection.clearSelection();
    for (int i = 0; i < table.getRowCount(); ++i) {
        T node = tableModel.getNode(table.convertRowIndexToModel(i));
        if (files.contains(node.getFile())) {
            selection.addSelectionInterval(i, i);
        }
    }
    selection.setValueIsAdjusting(false);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:VCSStatusTable.java

示例3: selectRows

import javax.swing.ListSelectionModel; //導入方法依賴的package包/類
private void selectRows(int[] selectedRows, int delta) {
    ListSelectionModel listSelectionModel = mappingsTable.getSelectionModel();
    listSelectionModel.clearSelection();
    for (int selectedRow : selectedRows) {
        listSelectionModel.addSelectionInterval(selectedRow + delta, selectedRow + delta);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:OptionsPanel.java

示例4: addFolders

import javax.swing.ListSelectionModel; //導入方法依賴的package包/類
private void addFolders( File files[] ) {
            int[] si = rootsList.getSelectedRows();
            int lastIndex = si == null || si.length == 0 ? -1 : si[si.length - 1];
            ListSelectionModel selectionModel = this.rootsList.getSelectionModel();
            selectionModel.clearSelection();
            Set<File> rootsFromOtherProjects = new HashSet<File>();
            Set<File> rootsFromRelatedSourceRoots = new HashSet<File>();
            String type = RootsAccessor.getInstance().getType(sourceRoots);
            boolean isModule = JavaProjectConstants.SOURCES_TYPE_MODULES.equals(type);
out:        for( int i = 0; i < files.length; i++ ) {
                File normalizedFile = FileUtil.normalizeFile(files[i]);
                Project p;
                if (ownedFolders.contains(normalizedFile)) {
                    Vector dataVector = rootsModel.getDataVector();
                    for (int j=0; j<dataVector.size();j++) {
                        //Sequential search in this minor case is faster than update of positions during each modification
                        File f = (File )((Vector)dataVector.elementAt(j)).elementAt(0);
                        if (f.equals(normalizedFile)) {
                            selectionModel.addSelectionInterval(j,j);
                        }
                    }
                }
                else if (this.relatedEditMediator != null && this.relatedEditMediator.ownedFolders.contains(normalizedFile)) {
                    rootsFromRelatedSourceRoots.add (normalizedFile);
                    continue;
                }
                if ((p=FileOwnerQuery.getOwner(Utilities.toURI(normalizedFile)))!=null && !p.getProjectDirectory().equals(project.getProjectDirectory())) {
                    final Sources sources = p.getLookup().lookup(Sources.class);
                    if (sources == null) {
                        rootsFromOtherProjects.add (normalizedFile);
                        continue;
                    }
                    final SourceGroup[] sourceGroups = sources.getSourceGroups(Sources.TYPE_GENERIC);
                    final SourceGroup[] javaGroups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
                    final SourceGroup[] groups = new SourceGroup [sourceGroups.length + javaGroups.length];
                    System.arraycopy(sourceGroups,0,groups,0,sourceGroups.length);
                    System.arraycopy(javaGroups,0,groups,sourceGroups.length,javaGroups.length);
                    final FileObject projectDirectory = p.getProjectDirectory();
                    final FileObject fileObject = FileUtil.toFileObject(normalizedFile);
                    if (projectDirectory == null || fileObject == null) {
                        rootsFromOtherProjects.add (normalizedFile);
                        continue;
                    }
                    for (int j=0; j<groups.length; j++) {
                        final FileObject sgRoot = groups[j].getRootFolder();
                        if (fileObject.equals(sgRoot)) {
                            rootsFromOtherProjects.add (normalizedFile);
                            continue out;
                        }
                        if (!projectDirectory.equals(sgRoot) && FileUtil.isParentOf(sgRoot, fileObject)) {
                            rootsFromOtherProjects.add (normalizedFile);
                            continue out;
                        }
                    }
                }
                int current = lastIndex + 1 + i;
                rootsModel.insertRow( current, new Object[] {normalizedFile, isModule
                            ? ((ModuleRoots)sourceRoots).createInitialPath()
                            : sourceRoots.createInitialDisplayName(normalizedFile)});
                selectionModel.addSelectionInterval(current,current);
                this.ownedFolders.add (normalizedFile);
            }
            if (rootsFromOtherProjects.size() > 0 || rootsFromRelatedSourceRoots.size() > 0) {
                rootsFromOtherProjects.addAll(rootsFromRelatedSourceRoots);
                showIllegalRootsDialog (rootsFromOtherProjects);
            }
            // fireActionPerformed();
        }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:69,代碼來源:SourceRootsUi.java


注:本文中的javax.swing.ListSelectionModel.clearSelection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。