本文整理汇总了Java中javax.swing.RowSorter.setSortKeys方法的典型用法代码示例。如果您正苦于以下问题:Java RowSorter.setSortKeys方法的具体用法?Java RowSorter.setSortKeys怎么用?Java RowSorter.setSortKeys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.RowSorter
的用法示例。
在下文中一共展示了RowSorter.setSortKeys方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setRowSorter
import javax.swing.RowSorter; //导入方法依赖的package包/类
public void setRowSorter(RowSorter<? extends TableModel> sorter) {
if (! (sorter instanceof TransactionTableRowSorter)) {
sorter = new TransactionTableRowSorter(this);
}
sorter.setSortKeys(Collections.singletonList(defaultSortKey()));
super.setRowSorter(sorter);
}
示例2: mouseClicked
import javax.swing.RowSorter; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
GridColumnsNode colGroup = cell.getColGroup();
if (colGroup.isLeaf() && colGroup.isSortable() && colGroup.getTableColumn() != null
&& cell.getHeader().getRowSorter() != null) {
RowSorter rowSorter = cell.getHeader().getRowSorter();
int modelIndex = colGroup.getTableColumn().getModelIndex();
if (!e.isControlDown() && (rowSorter.getSortKeys().size() != 1 || ((RowSorter.SortKey)rowSorter.getSortKeys().get(0)).getColumn() != modelIndex)) {
rowSorter.setSortKeys(new ArrayList<>());
}
rowSorter.toggleSortOrder(modelIndex);
}
}
示例3: resetSort
import javax.swing.RowSorter; //导入方法依赖的package包/类
public void resetSort() {
for (int i = 0; i < getColumnCount(); i++) {
RowSorter<?> sorter = getRowSorter();
List<SortKey> sortKeys = new ArrayList<>();
sortKeys.add(new RowSorter.SortKey(i, SortOrder.UNSORTED));
sorter.setSortKeys(sortKeys);
}
}
示例4: fillServerTable
import javax.swing.RowSorter; //导入方法依赖的package包/类
private void fillServerTable() {
final DefaultTableModel model = (DefaultTableModel) serverTable.getModel();
// reset sort order
final RowSorter<? extends TableModel> rowSorter = serverTable.getRowSorter();
rowSorter.setSortKeys(null);
// remove all rows
model.setNumRows(0);
displayedServerList.clear();
tServerURL.setText("");
// add new rows
boolean isCC = (session.getServiceType() == GameServiceType.ClassiCubeNetService);
final String searchTerm = tSearch.getText().toLowerCase();
for (final ServerListEntry server : serverList) {
if (server.name.toLowerCase().contains(searchTerm)) {
displayedServerList.add(server);
model.addRow(new Object[]{
server.name.replaceAll("\\s+", " "), // strip consecutive spaces
server.players,
server.maxPlayers,
server.uptime,
// CC.net servers show "Software" in the last column.
// MC.net servers show "Country" instead.
(isCC ? server.software : ServerListEntry.toCountryName(server.flag))
});
}
}
// select first server
if (model.getRowCount() > 0) {
serverTable.setRowSelectionInterval(0, 0);
}
}
示例5: resortByDefault
import javax.swing.RowSorter; //导入方法依赖的package包/类
void resortByDefault () {
RowSorter sorter = getRowSorter();
sorter.setSortKeys(Arrays.asList(new RowSorter.SortKey(2, SortOrder.ASCENDING)));
}
示例6: setData
import javax.swing.RowSorter; //导入方法依赖的package包/类
public void setData(List<Heuristic> heuristics) {
if (heuristics == null || heuristics.isEmpty()) {
return;
}
List<Heuristic> checkedHeuristics = checkHeuristics(heuristics);
String[][] data = new String[checkedHeuristics.size()][HEADERS.length];
int index = 0;
// Add sorting option to the columns!
for (Heuristic h : checkedHeuristics) {
if (h == null) {
continue;
}
String name = h.getName();
if (name == null || name.isEmpty()) {
continue;
}
String summary = h.getSummary();
String desc = h.getDescription();
//heuristicSummaryMap.put(name, summary);
heuristicsList.add(h);
Boolean result = h.getResult();
data[index][0] = name;
//data[index][1] = h.getType();
String status = null;
if (Boolean.TRUE.equals(result)) {
status = IHeuristic.STATUS_UNSAFE;
} else if (Boolean.FALSE.equals(result)) {
status = IHeuristic.STATUS_SAFE;
} else {
status = IHeuristic.STATUS_UNKNOWN;
}
data[index][COLUMN_INDEX_STATUS] = status;
index++;
}
RowSorter sorter = table.getRowSorter();
if (sorter != null) {
try {
sorter.setSortKeys(Arrays.asList(new RowSorter.SortKey(COLUMN_INDEX_STATUS, SortOrder.DESCENDING)));
} catch (Exception e) {
// ignore
}
}
model.setData(data);
model.fireTableDataChanged();
}