Solved

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

Posted on 2011-03-16
3
1,094 Views
Last Modified: 2012-05-11
Hi,

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

Thanks
Jamie
0
Comment
Question by:jamie_lynn
  • 2
3 Comments
 
LVL 47

Expert Comment

by:for_yan
ID: 35153173
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
 

Accepted Solution

by:
jamie_lynn earned 0 total points
ID: 35153733
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
 

Author Closing Comment

by:jamie_lynn
ID: 35178878
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question