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

Posted on 2011-03-16
Last Modified: 2012-05-11

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

Question by:jamie_lynn
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
LVL 47

Expert Comment

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.

Accepted Solution

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.


Author Closing Comment

ID: 35178878
public class OverlayIcon extends ImageIcon
private ImageIcon base;
private List overlays;

public OverlayIcon(ImageIcon base)
this.base = base;
this.overlays = new ArrayList();

public void add(ImageIcon overlay)

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);

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 had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
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.
Suggested Courses

623 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