Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a JTable that needs cell validation for the cells where the user can input text. When a user enters invalid text the border of the cell turns red.

I've managed to get this working associating a two dimension array to flag if each cell has errors or not.

The problem is that the user must be able to reorder the table (by column). I have to store the error flag in the table model, not separatly. Anyone has ideas how to do this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
98 views
Welcome To Ask or Share your Answers For Others

1 Answer

Also consider a custom TableCellEditor, seen here and below. Adding an InputVerifier, as shown here, is a good alternative.

As the user must be able to reorder the table by column:

JTable provides methods that convert from model coordinates to view coordinates — convertColumnIndexToView and convertRowIndexToView — and that convert from view coordinates to model coordinates — convertColumnIndexToModel and convertRowIndexToModel.

image


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...