Hi: everyone I got a problem about ActionListener. I want to use a button to control a JTextField in another class. but I am not sure how to do it. I do not know what's problem about my code, but I can not implement what I want to do.
Joined: Aug 14, 2001
To my thinking the easiest way to get this working would be to have the GUI stuff in one class. So I've defined a MyGUI class, which is controlled by a MyGUIApp class.
Hope this helps a little. It may not be the most elegant solution, but it works
SCJP 1.4, www.gsi3d.org.uk
Joined: Nov 15, 2003
Look at ur this line:
The "new" keyword will be creating a new Instance of Test4 class for every click on the button. Offcourse you can not see the new GUIs bcoz u are not calling builfGUI method.
If U want set a "hello World" text in the textfield for each button click, U have to do it on the existing instance of Test4 which has built ur GUI.
I have never coded in AWT. I can solve the problem but It may not be the right practise.
Check the books coz u missed the basics.
Joined: May 05, 2004
Thanks so much for your reply, Ben and J. J, you are right, I did not realized that before. thanks so much for you reply my question so fast, Ben and J. you are save me much time. really thanks.