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 am using a JTable in my GUI application as a grid to represent positions for a game. I want the cells of the table that represent a certain position of an object to have a certain color, and on some actions, the object to move (i.e the color cell to move around in the Grid /JTable). I know that I can change cell colors by making a class that extends DefaultTableCellRenderer , is this the only way it can be done? or is there a simpler way to chage cell colors??Also Is JXTable better than JTable for such an application ?

EDIT: I didn't include the fact that I need certain cell colors to change dynamically, i.e with button clicks, keyboard clicks ...etc, is that still possible with any TableCellRenderer in case I am still using JTable ?

Thanks,

See Question&Answers more detail:os

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

1 Answer

As an alternative, consider using prepareRenderer(), as suggested by @mKorbel and shown in the article Table Row Rendering.


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