For this answer I used the SimpleTableDemo. I simply add a MouseListener to the table. Here the MouseListener:
class MyMouseListener implements MouseListener {
public void mouseClicked(MouseEvent arg0) {}
public void mouseEntered(MouseEvent arg0) {}
public void mouseExited(MouseEvent arg0) {}
public void mousePressed(MouseEvent arg0) {}
public void mouseReleased(MouseEvent m) {
JTableHeader tableHeader = (JTableHeader)m.getComponent();
JTable table = tableHeader.getTable();
if (!table.getBounds().contains(m.getPoint())) {
table.removeColumn(table.getColumnModel().getColumn(
tableHeader.columnAtPoint(m.getPoint())));
}
}
}
This is a really basic way, there are no exception handled or wathever. But at least it works.