You must implement TableCellEditorand perform validation as part of the method stopCellEditing(). If validation fails, this method should return false. From Javadoc:
"Tells the editor to stop editing and accept some partially edited value as the value of the editor. The editor returns false if editing has not been stopped; this is useful for editors who check and cannot accept invalid entries ."
Take a look at the GenericEditor class defined in the JTableexample.
One more thing worth paying attention to: you can always build DefaultCellEditorwith JFormattedTextFieldas a parameter and add InputVerifierto the text box to prevent writing invalid data.
source
share