Reputation: 1
I have a label in my JFrame. It's variable name is l_1001
.
I want to get this variable name in output. How can I do it?
I tried
System.out.print(l_1001.getName())
But output rotates null
.
Upvotes: 0
Views: 1615
Reputation: 95948
See the docs, JLabel#getName()
:
Gets the name of the component.
In Java, you cannot simply return the name of the variable (without using reflection), you should set it before, you can use JLabel#setName
to do that.
Upvotes: 2