Currently in a Jtable there is a space for a name and then a combobox in each column header. When the header name is clicked I would like the default sorting to still take place but when the combobox is clicked I would like it to not sort.
I've tried consuming the mouseclick event when the combobox is clicked but the AWT event handlers have already received the event before my listener.
TableRowSorter is declared as such:
TableRowSorter<TableModel> tableRowSorter = (TableRowSorter<TableModel>) mainTable.getRowSorter();
tableRowSorter.addRowSorterListener(new RowSorterListener() {
@Override
public void sorterChanged(RowSorterEvent e) {
if (!(mainTable.getSelectedRow() < 0)) {
Rectangle r = mainTable.getCellRect(mainTable.getSelectedRow(), 0, true);
Point p = mainScrollPane.getViewport().getViewPosition();
r.setLocation(r.x, r.y - p.y);
mainScrollPane.getViewport().scrollRectToVisible(r);
}
}
});
//Section for popupmenu located in jtable class
aggregationMenu = new JPopupMenu();
aggregationMenu.setInvoker(this);
for (AggregationType type : AggregationType.values()) {
if (type == AggregationType.GROUP)
continue;
JMenuItem mi = new JMenuItem();
mi.setText(type.toString());
mi.addActionListener(this);
aggregationMenu.add(mi);
}