Java JLabel - Adds Unique Identifier

Can I add an identifier or a unique identifier in JLabel?

Thank you all

+3
source share
2 answers

JLabel has a setName method, which is inherited from java.awt.Component. You can use this for ID.

+4
source

You can call Component.setNameon it either a JComponent.putClientPropertysubclass or use the object JLabelas a key - that is Map.

But probably the way is to keep a reference to the source object so that you can write clean, direct code that should not look up the component.

+2
source

Source: https://habr.com/ru/post/1703890/


All Articles