本文整理汇总了Java中javax.swing.table.TableRowSorter.setSortsOnUpdates方法的典型用法代码示例。如果您正苦于以下问题:Java TableRowSorter.setSortsOnUpdates方法的具体用法?Java TableRowSorter.setSortsOnUpdates怎么用?Java TableRowSorter.setSortsOnUpdates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.table.TableRowSorter
的用法示例。
在下文中一共展示了TableRowSorter.setSortsOnUpdates方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: createSorter
import javax.swing.table.TableRowSorter; //导入方法依赖的package包/类
/** Get a table row sorter */
@Override
public RowSorter<ProxyTableModel<Controller>> createSorter() {
TableRowSorter<ProxyTableModel<Controller>> sorter =
new TableRowSorter<ProxyTableModel<Controller>>(this);
sorter.setSortsOnUpdates(true);
LinkedList<RowSorter.SortKey> keys =
new LinkedList<RowSorter.SortKey>();
keys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
sorter.setSortKeys(keys);
if (isFiltered())
sorter.setRowFilter(createFilter());
return sorter;
}
示例3: 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);
}
示例4: ResultTable
import javax.swing.table.TableRowSorter; //导入方法依赖的package包/类
public ResultTable(boolean team, List<Result> starts, FilterBox cd, FilterBox cg, ResultTable t, boolean m) {
super(new ResultTableModel(starts));
putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
getTableHeader().setReorderingAllowed(false);
TableRowSorter<ResultTableModel> sorter = new TableRowSorter<ResultTableModel>((ResultTableModel) getModel());
sorter.setSortsOnUpdates(true);
sorter.setRowFilter(new ResultRowFilter(team, cd, cg, t, m));
setRowSorter(sorter);
setDefaultRenderer(Float.class, new DefaultTableCellRenderer() {
{setHorizontalAlignment(SwingConstants.RIGHT);}
@Override
protected void setValue(Object o) {
super.setValue(String.format("%.1f", (Float) o));
}
});
getColumnModel().getColumn(1).setCellEditor(new TableEditor(new JComboBox<Discipline>(new DefaultComboBoxModel<Discipline>(Controller.get().getDisziplinen())), 0));
getColumnModel().getColumn(2).setCellEditor(new TableEditor(new JComboBox<Group>(new DefaultComboBoxModel<Group>(Controller.get().getConfig().getGroups())), 0));
for (int i = 0; i < 4; i++) {
getColumnModel().getColumn(i).setMinWidth(80);
getColumnModel().getColumn(i).setPreferredWidth(i < 3 ? 160: 80);
}
}
示例5: setRowSorter
import javax.swing.table.TableRowSorter; //导入方法依赖的package包/类
public void setRowSorter(final int column, final Comparator<?> comparator) {
final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(table.getModel());
sorter.setSortsOnUpdates(true);
sorter.setComparator(column, null);
setRowSorter(sorter);
sorter.setSortKeys(Arrays.asList(new RowSorter.SortKey(column, SortOrder.ASCENDING)));
}
示例6: 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);
}