Terai Atsuhiro 2015-03-17 (火) 18:44:01

http://terai.xrea.jp/swing/anchorselection/screenshot.png

//table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
table.getTableHeader().addMouseListener(new MouseAdapter() {
  public void mousePressed(MouseEvent e) {
    JTable table = ((JTableHeader)e.getSource()).getTable();
    if(table.isEditing()) {
      table.getCellEditor().stopCellEditing();
    }
    //table.getSelectionModel().clearSelection();
    //table.getSelectionModel().setAnchorSelectionIndex(-1);
    //table.getSelectionModel().setLeadSelectionIndex(-1);
    table.getColumnModel().getSelectionModel().setAnchorSelectionIndex(-1);
    table.getColumnModel().getSelectionModel().setLeadSelectionIndex(-1);
  }
});
table.changeSelection(table.getSelectedRow(),
                      table.getSelectedColumn(),
                      false, false);