当前位置: 首页>>代码示例>>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;未经允许,请勿转载。