1

I just want to know if there is any way to call a method from on an object by its name in a String.

Something like this

setLocation(int,int) it's a method from jLabel1, how can i call this
method(setLocation()) by using its name in string ?

String component = jLabel1.getName();
component.setLocation(x,y);
Majid Laissi
  • 19,188
  • 19
  • 68
  • 105

1 Answers1

0

Sure, you can use the Java reflection API

This SO question may helps you.

Community
  • 1
  • 1
Miguel Prz
  • 13,718
  • 29
  • 42