I want to develope stock ticker application in java. I dont know how to update JTable's specific cell's backcolour. In my application one thread running in background which randomly update's cell's text which is integer. I want to change cell's colour on the time of update. If previous cell's value is less than new value than cell's background colour shold become blue otherwise it would become blue. I am using my own cell renderer for this task. I am able to change cell's colour but on next update all the cell's colour change to default. I want that previously changed cell colour should remain same on next update. Please help me if u know the answer. Thanx in Advance.

Recommended Answers

All 3 Replies

I don't know who this "u" person is, but simply put that condition in your cell renderer. If you can update it once, you can certainly write a condition that determines if it should be updated again or stay the same.

I have tried the same but whenever table is repainted the old values are also set to default is there a way to remember previous stat of the table

That depends entirely on what determined the previous state of the table. Your cell renderer just needs enough info to determine, based upon it's value and location, how you want to render it. Not knowing a thing about how you are storing or updating the data that drives that decision, I can't tell you exactly how that should be coded.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.