本文整理汇总了Java中javax.swing.JTable.getRowSorter方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.getRowSorter方法的具体用法?Java JTable.getRowSorter怎么用?Java JTable.getRowSorter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTable
的用法示例。
在下文中一共展示了JTable.getRowSorter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSortKey
import javax.swing.JTable; //导入方法依赖的package包/类
/**
* Returns the current sort key, or null if the column is unsorted.
*
* @param table the table
* @param column the column index
* @return the SortKey, or null if the column is unsorted
*/
@SuppressWarnings("rawtypes")
protected SortKey getSortKey(JTable table, int column) {
RowSorter rowSorter = table.getRowSorter();
if (rowSorter == null) {
return null;
}
List sortedColumns = rowSorter.getSortKeys();
if (!sortedColumns.isEmpty()) {
return (SortKey) sortedColumns.get(0);
}
return null;
}
示例2: tabPaneStateChanged
import javax.swing.JTable; //导入方法依赖的package包/类
private void tabPaneStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_tabPaneStateChanged
JScrollPane sPane = (JScrollPane) tabPane.getSelectedComponent();
if (sPane != null) {
JViewport view = (JViewport) sPane.getComponent(0);
selectedTable = (JTable) view.getView();
// re-apply the filter to the current tab
if (selectedTable.getRowSorter() != null) {
((TableRowSorter) selectedTable.getRowSorter()).sort();
}
if (tabManagers != null) {
// Remove all toggle button listeners
for (ChangeListener l : autoScrollToggleButton.getChangeListeners()) {
autoScrollToggleButton.removeChangeListener(l);
}
LogTableManager manager = tabManagers.get(tabPane.getSelectedIndex());
// Add current listener
autoScrollToggleButton.addChangeListener(manager);
// Refresh buttons
autoScrollToggleButton.setSelected(manager.isAutoFollowScroll());
}
}
}
示例3: deleterow
import javax.swing.JTable; //导入方法依赖的package包/类
/**
* get all selected rows and DELETE one by one from the last.
*
* @param table the table to DELETE rows
*/
public static void deleterow(JTable table) {
int[] selectedrows = table.getSelectedRows();
for (int row : selectedrows) {
row = table.getSelectedRow();
if (table.getRowSorter() != null) {
row = table.getRowSorter().convertRowIndexToModel(row);
}
((DefaultTableModel) table.getModel()).removeRow(row);
}
}