Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-03-16
3
Medium Priority
?
1,149 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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…
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.
Suggested Courses

722 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