Is there anyway to add an ID or a unique identifier to a JLabel?
Thanks all
JLabel has a setName method that is inherited from java.awt.Component. You could use this for an ID.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With