Perry Smith

Java Questions & Answers

Home / Java Q & A Page 2 / Java Q & A Archive Main Page

Frames and Buttons
Monday, 16-Nov-98 13:14:13
195.11.50.203 writes:

I am writing a program which has a number of GUIs
I have created that all extend Frame. They all have buttons which once
clicked should call up one of the other GUIs. Problem is how do I do it?
Do I use mouseListener and write a MyMouseListener class or can I just
use addActionListener like in applets? And if I use MyMouseListener, do I
use getSource to find out which button has been clicked??
I would appreciate any help on this subject, Thank you!

Learner

Re: Frames and Buttons
Tuesday, 17-Nov-98 11:32:58
148.5.110.65 writes:

Learner,
You can just use addActionListener. I have found that to be the simplest
way. Then in your actionPerformed method you can either use getSource to
get the button or, I would suggest, using setActionCommand and
getActionCommand. The latter way of doing it does not require you to have
a "global" pointing to your buttons for testing.

Scott


Home / Java Q & A Page 2 / Java Q & A Archive Main Page