本文整理匯總了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();
}