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,107
  • 18
  • 130
  • 305

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
  • 91,013
  • 29
  • 181
  • 233