I have an ImageIcon that came from a transparent gif. Is there a way to
control how the background color is painted, for example setting the
background to red or white? Thanks.
|
|
0
|
|
|
|
Reply
|
mgart (32)
|
10/5/2006 9:25:27 PM |
|
mitch wrote:
> I have an ImageIcon that came from a transparent gif. Is there a way to
> control how the background color is painted, for example setting the
> background to red or white?
Try setBackground(color) and setOpaque(true) for the
component displaying the II.
HTH
Andrew T.
|
|
0
|
|
|
|
Reply
|
Andrew
|
10/6/2006 8:46:14 AM
|
|
mitch <mgart@kronos.com> wrote:
> I have an ImageIcon that came from a transparent gif. Is there a way to
> control how the background color is painted, for example setting the
> background to red or white? Thanks.
Untested:
class BackgroundImageIcon
extends ImageIcon
{
private Color background;
public BackgroundImageIcon(Image m, Color background)
{
super(m);
this.background = background;
}
// add other constructors
// super is synchronized - why??
public void paintIcon(Component c, Graphics g, int x, int y)
{
ImageObserver o = getImageObserver();
if (o == null)
o = c;
if (background != null) // ???
g.drawImage(getImage(), x, y, background, o);
else
g.drawImage(getImage(), x ,y, o);
}
}
|
|
0
|
|
|
|
Reply
|
usenet
|
10/10/2006 12:50:29 PM
|
|