Hi Craig Wood. I have tried out your code. But the problem is, when I have set the color in the combo box and I move on to the next element in the dialog. The color that has been set in the combo box go and the text select color appears there. I have use your renderer in the follwing just try running it.
thank you. It works now. Can you tell me why you have overridden the painComponen method in JComponent. I am just eager to know what went wrong with my code. [ April 11, 2006: Message edited by: Suman Mummaneni ]
thank you. It works now. Can you tell me why you have overridden the painComponen method in JComponent. I am just eager to know what went wrong with my code.
[ April 11, 2006: Message edited by: Suman Mummaneni ]
Should we do this overriding of paintComponent in the renderer for JTable if we want to have colours in the cells of the JTable.
Joined: Jan 14, 2004
I couldn't find the way to break into the plaf (look and feel) code to set the value in the JComboBox. Thought I had it the first time but didn't check focus-lost behavior. So I gave up on the plaf idea and tried a simpler approach: just paint the color for each JLabel. For JTables I think the original idea you had will work better. The difficulty with the JComboBox was in the difference between the JList (which uses the custom renderer) and the comboBox value (rendered in plaf code). We don't have this added complexity in JTable; everything is showing. You do have to build in enough state in the renderer class to be able to identify the row, column for the cell colors.