I have, for example, 2 text fields (txt1 and txt2) and two buttons (btn1 and btn2).
I want to build a single method that will set "hello" in txt1 if btn1 is pressed, or "hello" in txt2 if btn2 is pressed.
I thought about doing something like this:
txt1.setName("1"); txt2.setName("2");
in btn1 listener: setHello(txt1);
in btn2 listener: setHello(txt2);
setHello(String name){
(componentByName?(name)).setText("hello")
}
Is there a componentByName(name) method?