Validating cells in JTable

Hi everybody,

I want to validate text input in cells in a JTable. Once the user has finished the editing of a cell (by leaving it, pressing enter, pressing tab, etc.) I want to validate it (for example: check if it is empty or not). If the validation fails I want to make the border of that specific cell red. If the validation passes, nothing should happen.

My question is this: how can I best do such a thing? I suspect I need to use some kind of listenerer but which one? And how do I go about making the borders of specific cells red?

Best regards,

Jethro Borsje

[597 byte] By [Jethroa] at [2007-11-26 15:07:37]
# 1

Well, normally its better to edit the value before actually saving it. This posting shows one way to do this

http://forum.java.sun.com/thread.jspa?forumID=57&threadID=645740

On the other hand you may need to do cross editing among multiple fields when one field is changed. In this case editing would be done on the saved valude. In this case you would use a TableModelListener to listen for changed values.

camickra at 2007-7-8 8:57:41 > top of Java-index,Desktop,Core GUI APIs...