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); 
1
  • You would need to use Reflection. But what is the requirement, where you need to do something like this? Commented Feb 7, 2013 at 19:51

1 Answer 1

0

Sure, you can use the Java reflection API

This SO question may helps you.

Sign up to request clarification or add additional context in comments.

1 Comment

hm i will read the Reflection API thanks

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.