Paul Hayabusa wrote:How can i avoid to paint each time i edit a cell(writing the number)?
You cannot derive the coloring from the actual values in cells, because the table might need to repaint itself before the button was pressed, at which time the colors you want to see are not in accord with the cell value (which, I believe, is the difficulty you're encountering just now).
must paint the table "in the old way" until that button is actually pressed
Martin Vajsar wrote:At line 9, you're calling model.getValue(row, column), which contains value of the cell to be drawn, but inside this method, this value is available in the value parameter. It's not a mistake,
luck, db
There are no new questions, but there may be new answers.
Darryl Burke wrote:Obtaining any value from the model using the row, column parameters to the renderer method would return a wrong value if the table is sorted or its columns are reordered, as those parameters are the view coordinates. And that mistake is seen in line 14.
I also think that you still haven't fully grokked the JTable concepts. At line 9, you're calling model.getValue(row, column), which contains value of the cell to be drawn, but inside this method, this value is available in the value parameter. It's not a mistake, not a big one, but it shows that you still don't "instinctively" know how the table,
model and renderer cooperate to draw a cell. Perhaps you could try to go through the tutorial once more?
It this similar to what you want to achieve?
Paul Hayabusa wrote:Martin, can you elaborate your step 3?I dont understand very well the need for second loop and the why the change color in MyColorModel class.
We both need to be working on identical specs. The specification I've proposed doesn't speak about loading values from the database, but that can be easily changed -
and abstracted away, so that we can still have small, functioning code we can discuss. I cannot meaningfully assist you when you start trying to solve different specification without letting me know what that specification is.
Paul Hayabusa wrote:
There is two values: minValue and maxValue.The rest is like you wrote.If the cell BETWEEN minValue and maxValue, BLUE, if not, RED.
Lets say min and max are 10 and 50.If the cell is 40, color will be blue, if its 60, RED.
Paul Hayabusa wrote:When i press JButton(after writing 40 in one cell) ALL rows got blue colored.
Thank you my well lotioned goddess! Here, have my favorite tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|