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


Java TableRowSorter.sort方法代碼示例

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


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

示例1: updateClusterTable

import javax.swing.table.TableRowSorter; //導入方法依賴的package包/類
private void updateClusterTable() {
	int index = annotationSetCombo.getSelectedIndex();
	AnnotationSet annotationSet = annotationSetCombo.getItemAt(index).getValue();
	ClusterTableModel clusterModel = new ClusterTableModel(annotationSet);
	
	int widths[] = getColumnWidths(clusterTable);
	clusterTable.setModel(clusterModel);
	setColumnWidths(clusterTable, widths);
	TableColumn collapsedColumn = clusterTable.getColumnModel().getColumn(ClusterTableModel.COLLAPSED_COLUMN_INDEX);
	collapsedColumn.setCellRenderer(new ClusterTableCollapsedCellRenderer(iconManager));
	
	
	// sort
	TableRowSorter<TableModel> sorter = new TableRowSorter<>(clusterTable.getModel());
	clusterTable.setRowSorter(sorter);
	List<SortKey> sortKeys = new ArrayList<>(2);
	sortKeys.add(new RowSorter.SortKey(ClusterTableModel.NODES_COLUMN_INDEX, SortOrder.DESCENDING));
	sortKeys.add(new RowSorter.SortKey(ClusterTableModel.CLUSTER_COLUMN_INDEX, SortOrder.ASCENDING));
	sorter.setSortKeys(sortKeys);
	sorter.sort();
}
 
開發者ID:BaderLab,項目名稱:AutoAnnotateApp,代碼行數:22,代碼來源:ClusterPanel.java

示例2: setSorter

import javax.swing.table.TableRowSorter; //導入方法依賴的package包/類
private void setSorter(TableModel model) {
    TableRowSorter<TableModel> sorter = new TableRowSorter<>(model);
    sorter.setSortsOnUpdates(true);
    LinkedList<RowSorter.SortKey> sortKeys = new LinkedList<>();
    sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
    sorter.setSortKeys(sortKeys);
    sorter.sort();
    setRowSorter(sorter);
}
 
開發者ID:Blazemeter,項目名稱:jmeter-debugger,代碼行數:10,代碼來源:HighlightTable.java

示例3: setLayout4JTableComponents

import javax.swing.table.TableRowSorter; //導入方法依賴的package包/類
/**
   * Sets the layout for the JTable of the NetworkComponents.
   */
  private void setLayout4JTableComponents() {
  	
  	// --- Set Sorter for the table -------------------
TableRowSorter<DefaultTableModel> tblSorter = new TableRowSorter<DefaultTableModel>(this.getDefaultTableModel4Components());
   this.getJTableComponents().setRowSorter(tblSorter);		    
  
   // --- Define a comparator for the first row ------
tblSorter.setComparator(0, new Comparator<String>() {
	@Override
	public int compare(String netCompId1, String netCompId2) {
		Integer ncID1 = null;
		Integer ncID2 = null;
		try {
			ncID1 = Integer.parseInt(netCompId1.replaceAll("\\D+",""));
			ncID2 = Integer.parseInt(netCompId2.replaceAll("\\D+",""));
		} catch (NumberFormatException nfe) {
		}

		if (ncID1!=null & ncID2!=null) {
			return ncID1.compareTo(ncID2);
		}
		return netCompId1.compareTo(netCompId2);
	}
});
 // --- Define the first sort order ----------------
List<SortKey> sortKeys = new ArrayList<SortKey>();
for (int i = 0; i < this.getJTableComponents().getColumnCount(); i++) {
    sortKeys.add(new SortKey(i, SortOrder.ASCENDING));
}
tblSorter.setSortKeys(sortKeys);
tblSorter.sort();

// --- Define the column widths -------------------
TableColumnModel colModel = this.getJTableComponents().getColumnModel();
colModel.getColumn(0).setPreferredWidth(40);
colModel.getColumn(0).setCellRenderer(new BasicGraphGuiTableCellRenderEditor());
colModel.getColumn(0).setCellEditor(new BasicGraphGuiTableCellRenderEditor());			

colModel.getColumn(1).setPreferredWidth(40);
colModel.getColumn(1).setCellRenderer(new BasicGraphGuiTableCellRenderEditor());

colModel.getColumn(2).setPreferredWidth(30);
colModel.getColumn(2).setCellRenderer(new TableCellRenderer4Button());
colModel.getColumn(2).setCellEditor(new TableCellEditor4TableButton(getGraphController(), jTableComponents));			

  }
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:50,代碼來源:BasicGraphGuiRootJSplitPane.java

示例4: setRowSorter

import javax.swing.table.TableRowSorter; //導入方法依賴的package包/類
public void setRowSorter(final TableRowSorter<? extends TableModel> sorter) {
	table.setRowSorter(sorter);
	sorter.sort();
}
 
開發者ID:processmining,項目名稱:synthetic-log-generator,代碼行數:5,代碼來源:ProMTable.java

示例5: updateIssuesTable

import javax.swing.table.TableRowSorter; //導入方法依賴的package包/類
private void updateIssuesTable() {
    List<ScanTreeNode> selectedNodes = Lists.newArrayList((ScanTreeNode) issuesComponentsTree.getModel().getRoot());
    if (issuesComponentsTree.getSelectionPaths() != null) {
        selectedNodes.clear();
        TreePath[] selectedTreeNodes = issuesComponentsTree.getSelectionPaths();
        for (TreePath treePath : selectedTreeNodes) {
            selectedNodes.add((ScanTreeNode) treePath.getLastPathComponent());
        }
    }

    TableModel model = ScanManagerFactory.getScanManager(project).getFilteredScanIssues(selectedNodes);
    TableRowSorter<TableModel> sorter = new TableRowSorter<>(model);
    issuesTable.setRowSorter(sorter);
    issuesTable.setModel(model);

    List<RowSorter.SortKey> sortKeys = new ArrayList<>();
    sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
    sorter.setSortKeys(sortKeys);
    sorter.sort();

    resizeTableColumns();
    issuesTable.validate();
    issuesTable.repaint();
}
 
開發者ID:JFrogDev,項目名稱:jfrog-idea-plugin,代碼行數:25,代碼來源:XrayToolWindow.java


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