Solved

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

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jmss example java 2 48
Java syntax, or is it Selenium 6 61
Eclipse for Java EE development 2 68
How do i find out all classes which contain nested class 2 14
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…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

738 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