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


Java TableRowSorter.toggleSortOrder方法代码示例

本文整理汇总了Java中javax.swing.table.TableRowSorter.toggleSortOrder方法的典型用法代码示例。如果您正苦于以下问题:Java TableRowSorter.toggleSortOrder方法的具体用法?Java TableRowSorter.toggleSortOrder怎么用?Java TableRowSorter.toggleSortOrder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.table.TableRowSorter的用法示例。


在下文中一共展示了TableRowSorter.toggleSortOrder方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ParameterTablePanel

import javax.swing.table.TableRowSorter; //导入方法依赖的package包/类
ParameterTablePanel(JHVEventParameter[] parameters) {
    setLayout(new BorderLayout());

    ParameterTableModel parameterModel = new ParameterTableModel(parameters);
    JTable table = new WrappedTable();
    table.setModel(parameterModel);
    table.setAutoCreateRowSorter(true);
    table.getColumnModel().getColumn(0).setResizable(false);
    table.getColumnModel().getColumn(0).setMaxWidth(180);
    table.getColumnModel().getColumn(0).setPreferredWidth(180);
    table.getColumnModel().getColumn(1).setPreferredWidth(200);
    table.getColumnModel().getColumn(1).setCellRenderer(new WrappedTextRenderer());
    table.setPreferredScrollableViewportSize(new Dimension(table.getWidth(), 150));
    // table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    TableRowSorter<ParameterTableModel> sorter = new TableRowSorter<>(parameterModel);
    sorter.toggleSortOrder(0);
    table.setRowSorter(sorter);

    table.addMouseMotionListener(this);
    table.addMouseListener(this);

    add(new JScrollPane(table), BorderLayout.CENTER);
}
 
开发者ID:Helioviewer-Project,项目名称:JHelioviewer-SWHV,代码行数:25,代码来源:ParameterTablePanel.java

示例2: getJTablePjtList

import javax.swing.table.TableRowSorter; //导入方法依赖的package包/类
/**
 * This method initializes jTablePjtList	
 * 	
 * @return javax.swing.JTable	
 */
 	@SuppressWarnings("unchecked")
private JTable getJTablePjtList() {
	if (jTablePjtList == null) {
		
		jTablePjtList = new JTable(getProjectTableModel());
		getProjectTableModel().setColumnWidth(jTablePjtList);
		getProjectTableModel().setColumnType(jTablePjtList);
		jTablePjtList.addMouseListener(new ProjectTableClickAction());
		
		TableRowSorter sorter = new TableRowSorter(managedProjectTableModel);  
		sorter.setComparator(ManagedProjectTableModel.COL_DELETE, new ProjectTableComparator());  
		sorter.setComparator(ManagedProjectTableModel.COL_PROJECT_NAME, new ProjectTableComparator());  
		sorter.setComparator(ManagedProjectTableModel.COL_ANALYZE_TARGET, new ProjectTableComparator());  
		sorter.setComparator(ManagedProjectTableModel.COL_ANALYZE_STATUS, new ProjectTableComparator());   
		sorter.setComparator(ManagedProjectTableModel.COL_SOURCE_LOCATION, new ProjectTableComparator());   
		sorter.toggleSortOrder(ManagedProjectTableModel.COL_PROJECT_NAME);
		jTablePjtList.setRowSorter(sorter);			
	}
	return jTablePjtList;
}
 
开发者ID:spdx,项目名称:ATTIC-osit,代码行数:26,代码来源:JPanManageMain.java

示例3: setupTable

import javax.swing.table.TableRowSorter; //导入方法依赖的package包/类
public FormattedTableModel<RowData> setupTable() {
    FormattedTableModel<RowData> tableModel = new FormattedTableModel<>(needCheckboxes, getColumnDefs());

    table.setModel(tableModel);

    if (sortableColumns) {
        TableRowSorter<FormattedTableModel<RowData>> rowSorter = new TableRowSorter<>(tableModel);
        table.setRowSorter(rowSorter);

        rowSorter.setSortsOnUpdates(sortsOnUpdates);
        if (initialSortColumnIndex >= 0 && initialSortColumnIndex < columnInfos.size()) {
            rowSorter.toggleSortOrder(initialSortColumnIndex);
        }
    }
    else {
        table.setRowSorter(null);
    }

    TableColumnModel columnModel = table.getColumnModel();

    int index = 0;
    for (ColumnInfo<RowData> columnInfo: columnInfos) {
        columnInfo.config.setupColumn(columnModel.getColumn(index));
        index++;
    }

    return tableModel;
}
 
开发者ID:AlphaHearth,项目名称:AlphaHearth,代码行数:29,代码来源:JTableBuilder.java

示例4: testShareSorterRemoveLastRow

import javax.swing.table.TableRowSorter; //导入方法依赖的package包/类
/**
 * RowSorter not shareable!
 * Here: remove last row of model - fails immediately with OOB exception
 */
@Test
public void testShareSorterRemoveLastRow() {
    DefaultTableModel model = new DefaultTableModel(10, 1);
    TableRowSorter<DefaultTableModel> sorter = new TableRowSorter<DefaultTableModel>(model);
    int last = model.getRowCount() - 1;
    JTable table = new JTable(model);
    table.setRowSorter(sorter);
    JTable other = new JTable(model);
    other.setRowSorter(sorter);
    sorter.toggleSortOrder(0);
    sorter.toggleSortOrder(0);
    model.removeRow(last);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:18,代码来源:DefaultRowSorterIssues.java

示例5: testShareSorterRemoveFirstRow

import javax.swing.table.TableRowSorter; //导入方法依赖的package包/类
/**
 * RowSorter not shareable!
 * 
 * Here: remove first row of model - no exception, incorrect view row count
 */
@Test
public void testShareSorterRemoveFirstRow() {
    DefaultTableModel model = new DefaultTableModel(10, 1);
    TableRowSorter<DefaultTableModel> sorter = new TableRowSorter<DefaultTableModel>(model);
    int last = model.getRowCount() - 1;
    JTable table = new JTable(model);
    table.setRowSorter(sorter);
    JTable other = new JTable(model);
    other.setRowSorter(sorter);
    sorter.toggleSortOrder(0);
    sorter.toggleSortOrder(0);
    model.removeRow(0);
    assertEquals(last, table.getRowCount());
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:20,代码来源:DefaultRowSorterIssues.java

示例6: setModel

import javax.swing.table.TableRowSorter; //导入方法依赖的package包/类
public void setModel(Set<List<String>> tickersAndCompanies) {
    setColumnModel(new TickerCompanyTableColumnModel("Ticker", "Company"));
    TickerCompanyTableModel model = new TickerCompanyTableModel(tickersAndCompanies);
    setModel(model);
    TableRowSorter<TickerCompanyTableModel> rowSorter = new TableRowSorter<TickerCompanyTableModel>(model);
    setRowSorter(rowSorter);
    rowSorter.toggleSortOrder(0);
}
 
开发者ID:objektwerks,项目名称:swing,代码行数:9,代码来源:TickerCompanyTable.java

示例7: setModel

import javax.swing.table.TableRowSorter; //导入方法依赖的package包/类
public void setModel(Set<List<String>> tickersAndCompanies) {
    setColumnModel(new StatisticsTableColumnModel("Statistic", "Value"));
    StatisticsTableModel model = new StatisticsTableModel(tickersAndCompanies);
    setModel(model);
    TableRowSorter<StatisticsTableModel> rowSorter = new TableRowSorter<StatisticsTableModel>(model);
    setRowSorter(rowSorter);
    rowSorter.toggleSortOrder(0);
}
 
开发者ID:objektwerks,项目名称:swing,代码行数:9,代码来源:RegimeStatisticsTable.java

示例8: createRowSorter

import javax.swing.table.TableRowSorter; //导入方法依赖的package包/类
private TableRowSorter<StockTableModel> createRowSorter(StockTableModel model, List<String> columns) {
    TableRowSorter<StockTableModel> rowSorter = new TableRowSorter<StockTableModel>(model);
    for (int i = 0; i < columns.size(); i++) {
        rowSorter.setComparator(i, DoubleAsStringComparator.instance);
    }
    rowSorter.toggleSortOrder(0);
    return rowSorter;
}
 
开发者ID:objektwerks,项目名称:swing,代码行数:9,代码来源:StockTable.java

示例9: createControls

import javax.swing.table.TableRowSorter; //导入方法依赖的package包/类
private void createControls(final List<BaseType> baseTypes) {
  setBorder(new EmptyBorder(5, 5, 5, 5));
  final GridBagLayout gridBagLayout = new GridBagLayout();
  gridBagLayout.columnWidths = new int[] {0, 0, 0};
  gridBagLayout.rowHeights = new int[] {0, 0, 0, 0, 0};
  gridBagLayout.columnWeights = new double[] {0.0, 1.0, Double.MIN_VALUE};
  gridBagLayout.rowWeights = new double[] {0.0, 0.0, 1.0, 1.0, Double.MIN_VALUE};
  setLayout(gridBagLayout);

  final JLabel lblName = new JLabel("Name:");
  GridBagConstraints gbcLblName = new GridBagConstraints();
  gbcLblName.insets = new Insets(0, 0, 5, 5);
  gbcLblName.anchor = GridBagConstraints.WEST;
  gbcLblName.gridx = 0;
  gbcLblName.gridy = 0;
  add(lblName, gbcLblName);

  name = new JTextField();
  GridBagConstraints gbcName = new GridBagConstraints();
  gbcName.insets = new Insets(0, 0, 5, 0);
  gbcName.fill = GridBagConstraints.HORIZONTAL;
  gbcName.gridx = 1;
  gbcName.gridy = 0;
  add(name, gbcName);
  name.setColumns(10);

  final JLabel lblMembers = new JLabel("Members:");
  final GridBagConstraints gbcLblMembers = new GridBagConstraints();
  gbcLblMembers.anchor = GridBagConstraints.WEST;
  gbcLblMembers.insets = new Insets(0, 0, 5, 5);
  gbcLblMembers.gridx = 0;
  gbcLblMembers.gridy = 2;
  add(lblMembers, gbcLblMembers);

  final MemberTableModel model = new MemberTableModel();
  model.addTableModelListener(new MemberTableModelListener());
  members = new MemberTable(model, baseTypes);
  final TableRowSorter<MemberTableModel> sorter = new TableRowSorter<MemberTableModel>(model);
  // Triggers immediate re-sort when offset is updated.
  sorter.setSortsOnUpdates(true);
  sorter.setSortable(MemberTableModel.NAME_COLUMN, false);
  sorter.setSortable(MemberTableModel.TYPE_COLUMN, false);
  // Initial state is ascending sort order.
  sorter.toggleSortOrder(MemberTableModel.INDEX_COLUMN);
  members.setRowSorter(sorter);

  final GridBagConstraints gbcMembers = new GridBagConstraints();
  gbcMembers.insets = new Insets(0, 0, 5, 0);
  gbcMembers.fill = GridBagConstraints.BOTH;
  gbcMembers.gridx = 1;
  gbcMembers.gridy = 2;
  add(new JScrollPane(members), gbcMembers);

  final JLabel lblPreview = new JLabel("Preview:");
  final GridBagConstraints gbcLblPreview = new GridBagConstraints();
  gbcLblPreview.anchor = GridBagConstraints.WEST;
  gbcLblPreview.insets = new Insets(0, 0, 0, 5);
  gbcLblPreview.gridx = 0;
  gbcLblPreview.gridy = 3;
  add(lblPreview, gbcLblPreview);

  final JTextArea preview = new JTextArea();
  final GridBagConstraints gbcPreview = new GridBagConstraints();
  gbcPreview.fill = GridBagConstraints.BOTH;
  gbcPreview.gridx = 1;
  gbcPreview.gridy = 3;
  add(preview, gbcPreview);
}
 
开发者ID:google,项目名称:binnavi,代码行数:69,代码来源:ComplexTypePanel.java

示例10: createRowSorter

import javax.swing.table.TableRowSorter; //导入方法依赖的package包/类
private TableRowSorter<CriteriaComponentTableModel> createRowSorter(CriteriaComponentTableModel model) {
    TableRowSorter<CriteriaComponentTableModel> rowSorter = new TableRowSorter<CriteriaComponentTableModel>(model);
    rowSorter.setComparator(0, criteriaComponentComparator);
    rowSorter.toggleSortOrder(0);
    return rowSorter;
}
 
开发者ID:objektwerks,项目名称:swing,代码行数:7,代码来源:CriteriaComponentTable.java

示例11: sort

import javax.swing.table.TableRowSorter; //导入方法依赖的package包/类
/**
       * Toggle-sort a column
       * @param columnIndex The index of the column to be sorted
       */
@SuppressWarnings({ "unchecked", "rawtypes" })
private void sort(int columnIndex){
	// Get the default, already registered, sorter
	TableRowSorter sorter = (TableRowSorter)getTable().getRowSorter();
	// Ensure the row is sortable
	sorter.setSortable(columnIndex, true); 
	// Disable the row sorting capability to remove the native functionality
	sorter.toggleSortOrder(columnIndex);
	// Let all listeners (ui-display-related objects) know that we've sorted, so
	// please repaint()
	int rowCount = getTable().getRowCount();
	getModel().fireTableRowsUpdated(0, rowCount - 1);
	// If the column clicked doesn't match the last column that was sorted, there is
	// no need to toggle, and we'll just sort descending
	if (lastSorted != columnIndex){
		descending = true;
		lastSorted = columnIndex;
	}
	// If the direction is descending, sort descending
	if (descending){
		sorter.setSortKeys( Arrays.asList( new RowSorter.SortKey( columnIndex, SortOrder.DESCENDING ) ) );
	}
	// Otherwise, sort ascending
	else {
		sorter.setSortKeys( Arrays.asList( new RowSorter.SortKey( columnIndex, SortOrder.ASCENDING ) ) );
	}
	// Toggle the sort direction, in case we click on the chosen column again
	descending = !descending;
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:34,代码来源:GridPlaySheet.java


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