Solved

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

Posted on 2011-03-16
3
1,068 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now