java question

Joel Buckingham jbuckingham1 at kc.rr.com
Sat May 15 16:36:59 CDT 2004


Ben Coffman wrote:

> I have a java program and I want to change the color on and 
> ImageIcon.  I have it set up so I can change the color on the icon, 
> but I have to close the icon and then bring it back up again to get 
> then new color that I set it too.  Is there a way that I can change 
> the color on the ImageIcon so I don't have to close it and re-open it 
> to see the color change?
>
> Ben
>
>
>
Java GUI's really aren't my bag of tea, but have you tried to do a 
repaint() or a paint() on the object to which you've added the 
ImageIcon. Here's a slightly modified example from the HowTo on How to 
Use Icons at java.sun.com.

ImageIcon icon = createImageIcon("images/middle.gif", "a pretty but meaningless splat");
label1 = new JLabel("Image and Text", icon, JLabel.CENTER);
...

//perform color changes here
...

label1.repaint(g);

If that doesn't work, send me some of your code off list and I'll take a 
look at it.

-Joel




More information about the Kclug mailing list