Reject invalid text in JTable CellEditor?

B

Boris Pelakh

I have a JTable with editable fields. The values of one of the columns
must be unique. Therefore, I would like to reject any non-unique value
entered into that column.

Ideally, pressing 'Enter' would not stop the editing when an invalid
value is in the cell. Alternately, I can just complain on the status
bar and force the user to edit the cell again, but that's not as
pretty.

Is there a hook somewhere in CellEditor to let me do that?

-- Boris
 
V

VisionSet

Boris Pelakh said:
I have a JTable with editable fields. The values of one of the columns
must be unique. Therefore, I would like to reject any non-unique value
entered into that column.

Ideally, pressing 'Enter' would not stop the editing when an invalid
value is in the cell. Alternately, I can just complain on the status
bar and force the user to edit the cell again, but that's not as
pretty.

Is there a hook somewhere in CellEditor to let me do that?

Does this help:

http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#validtext

http://java.sun.com/docs/books/tutorial/uiswing/components/example-1dot4/IntegerEditor.java
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top