0

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.

mKorbel
  • 109,525
  • 20
  • 134
  • 319

1 Answers1

2

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.

Maroun
  • 94,125
  • 30
  • 188
  • 241