Link to home
Start Free TrialLog in
Avatar of ViceroyFizzlebottom
ViceroyFizzlebottomFlag for United States of America

asked on

Button event handling in JApplet

Hey there. I have an applet that has some input textboxes and two buttons.
The general format is this:
public class Install extends JApplet implements ActionListener
{}

Anyway, I'm having a hard time figuring out how to handle the button clicks as far as how to implement the
actionPerformed() method. Where should the actionPerformed method be defined and what is the best way
to handle the two button events?
Any help is appreciated.
Avatar of aozarov
aozarov

Have a look at: http://javaalmanac.com/egs/javax.swing/combobox_CbActionEvt.html
This sample code is for JComboBox but the same style of getting / handling the event can applied on JButton.
Basically you need to call addActionListener(actionListener) on each one of your JButton and pass an ActionListener
that will handle the event.
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial