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