you've added another field for the value, but forgot to add another field for color. So you need to modify MyColorRow and MyColorModel to support different colors of different columns in a row.
Paul Hayabusa wrote:How can i make my code more friendly to use?I have 5 other classes who need the same: Evaluate two columns of JTable and color.The only difference is the cell position(some are 0 and 1, others 8 and 9...).I will have to create 6 models,6 different colorows....more 6 different AnalyzeButtons...wow!
Another thing:What s the problem with MyColorRenderer other user has talked about it?
Paul Hayabusa wrote:Martin, i found the bug!It was:
And the coloring only in one color per row continues!
Paul Hayabusa wrote:yeah, i saw a part of my mistake when you told me to search the cell postition!
But i am still getting the same behavior(it colors ALL rows).Where i am wrong?
I'll ask you an additional question: how many different colors can the MyColorRow class store? And, given that one row is represented by exactly one instance of this
class, can one row ever be rendered in more than one color?
If you really traced the origins of the color used in the renderer, you'd probably see the bug for yourself.
Paul Hayabusa wrote:MyColorRow can store only ONE color per instance.But how can i change that, if the model is not CELL oriented?How can i tie that to have two idependent cell color working?
Paul Hayabusa wrote:You told i have something to REMOVE from my table model, but i cant see what.
It can be found in the last version of the MyColorModel class you posted on Wednesday. Doing more tests by adding further modifications to the code won't help until you remove that bug.
I had thought this will be easy, since you've added another column and a field for its value, including modifications to the model, without any apparent problems.
You don't want to associate two colors with one cell.
I dont have anymore the problem of color ALL rows.
But I'm really not a good teacher.
in the lines i have called setColorAt.
java.lang.IndexOutOfBoundsException: Invalid range
Paul Hayabusa wrote:But dont workswell... there is some way more elegant to test two colums at same time without tie my code with a bunch of if´s or i will have to do always something like that:
If this is true, you could write a separate method for coloring the first column and the second column, or - perhaps even better - a method that would take an int value of the cell and returned the color (or null if there should be no explicit coloring). You'll don't need to evaluate the value and value2 in the same if condition
a method that would take an int value of the cell and returned the color (or null if there should be no explicit coloring). You'll don't need to evaluate the value and value2 in the same if condition.
Paul Hayabusa wrote:
The only problem is when i edit, they remain the prior color till i have pressed jbutton.
I will change that controlling cell Focus.