tags:

views:

274

answers:

2

Hello all,

Is there anyway to add an ID or a unique identifier to a JLabel?

Thanks all

+2  A: 

JLabel has a setName method that is inherited from java.awt.Component. You could use this for an ID.

Mark
+2  A: 

You can call Component.setName on it, or JComponent.putClientProperty, or subclass or use the JLabel object as a key is a Map of some sort.

But probably the way to go is to keep hold of a reference to the original object, so you can write clean, direct code that doesn't have to look the component up.

Tom Hawtin - tackline