Is it possible to remove an Icon or ImageIcon once it is set to a JButton or JLabel?
When a specific action in my program has taken place, the picture in no more appropriate and I want to remove it from a JLabel.

Just set the JLabel's imageicon to null

Does not seem to work.
To try it, I wrote:

alarmLab.setIcon(labIcon);
labIcon = null;

The icon stays visible.

That just nulls your local variable. You need to tell the JLabel to use a null icon, eg:
myJLabel.setIcon(null);

Yes James, that worked.

Thank you.

OK. When you have an answer can you please mark your threads "solved" for our knowledge base. Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.