Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1176
  • Last Modified:

What is the best way to do icon overlay in Java?

Hi,

What is the best way to do icon overlay in Java?

Thanks
Jamie
0
jamie_lynn
Asked:
jamie_lynn
  • 2
1 Solution
 
for_yanCommented:
What do you mean by icon overlay?
Are you talking about some visual lement, like JList, JTable, or something else?
Please, be a little bit more specific.
0
 
jamie_lynnAuthor Commented:
Hi for_yan,

I meant 2 icon images displayed, one overlayed ontop of the other.
Like an "x" on top of a connection icon, if the connection is broken.

But i found the solution.
http://forums.java.net/node/678566

Thanks!
0
 
jamie_lynnAuthor Commented:
public class OverlayIcon extends ImageIcon
{
private ImageIcon base;
private List overlays;

public OverlayIcon(ImageIcon base)
{
super(base.getImage());
this.base = base;
this.overlays = new ArrayList();
}

public void add(ImageIcon overlay)
{
overlays.add(overlay);
}

@Override
public synchronized void paintIcon(Component c, Graphics g, int x, int y)
{
base.paintIcon(c, g, x, y);
for(ImageIcon icon: overlays)
{
icon.paintIcon(c, g, x, y);
}
}
}
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now