2
我有一個RowSorterListener。我希望能夠告訴哪一列火災RowSorterEvent
。但是,當我試圖獲得專欄時,我沒有得到我想要的輸出。獲取啓動的列RowSorterEvent
public class CustomRowSorterListener implements RowSorterListener {
JTable table;
public CustomRowSorterListener(JTable table) {
this.table = table;
}
@Override
public void sorterChanged(RowSorterEvent e)
{
//Attempt 1
System.out.println(e.getSource()); //Returns RowSorter and not a column
//Attempt 2
System.out.println(e.getSource().getColumn()); //Caused error in code
//Attempt 3
System.out.println(table.getColumn()) //Didn't work because no arguments were
//provided. However, I was unsure if it could
//be done this way.
//System.out.println(table.getColumn(e.getSource())) also doesn't work
}
}
我將不勝感激任何幫助獲得解決方案的工作。
TableColumnModel中可以重新排序,不得不指數從視圖轉換從鼠標和的KeyEvents模型,RowSorterEvent直接返回從XxxTableModel – mKorbel