2
votes

This Scenario may sound silly... but this was the observation...

When a mouse click on the the JTable cell... Cell is gets into the editor mode, while in the editor and a invalid entry is made (JTextFeild Component is installed in each cell), the focus is restricted in the editor mode by returning false instead of super.return stopCellEditing(); while validation and test field is painted red.

In the false mode, if user clicks anywhere on the table or outside the table the focus is not lost, but when the user clicks on the JTable header the focus is lost from the cell... I need to restrict this... How can this be achieved

Thank You in Advance...

3
@trashgod .. ehh ... how is the autocreateRowSorter related to this? starting to believe that I read a question different from the one all others read :-) - kleopatra
Why would you want to do this? It may help to provide an sscce that exhibits the problem you describe. - trashgod
Thanks... just out of curiosity... thanks for the link @trashgod - Jeetesh Nataraj

3 Answers

2
votes

just to make sure: the editing is canceled in that case (though not exactly on click but on any mouse gesture which might be interpreted as starting a column move/resize, if I remember correctly), right?

If so, it's

  • a long standing bug, table silently removes editors on receiving change notifications from the column model
  • even if fixed, (arguably, of course) not the best user experience to not allow moving out
2
votes

You might look at @camickr's TablePopupEditor, which uses a modal dialog to edit.

1
votes

This can actually be possible by disabling

table.getTableHeader().setReorderingAllowed(false); table.getTableHeader().setResizingAllowed(false);

Currently its working, but don't know under what circumstances it may fail.

Thank You