Use:
TextField t = findNameOfMyTextField(c);
문제
Right now,
i am casting it down to its type. If I use it in an ActionListener
, I'm declaring it as final:
final TextField tf = ((TextField)c);
tf = tf.getText();
Here,
Component c
is the parameter of the action method.
There doesn't seem to be a method in Component
or in anyone of the descendants returning the component instance. The name of the component in Designer interface didn't work either.
One other i can think of is using ActionEvent.getSource()
. I haven't tried it yet-- there should be a more direct way(?)
해결책
Use:
TextField t = findNameOfMyTextField(c);