0

In applet we are using init() method so inside of the init() method can we use the actionPerformed method or can't?.If we couldn't which place can be implements that action performend method.

Also you just give me the syntax for creating the actionperformed method in applet.And that applet must have implements init() method


Advance Thanks...

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by mKorbel
1

You don't call the actionperformed. It is automatically called whenever you click a button.
You implement it normally in the same way you do when you use javax.swing. Your applet should implement the ActionListener interface, then you will declare the actionPerformed method and write code inside it. Then you will add to your buttons that ActionListener (namely the applet like you do with normal java GUI).

If you want to call the actionPerformed method explicitely meaning you want to call the code inside in some cases, I would suggest to either call directly the code you put inside the actionPerformed method, or trigger the button clicked yourself. The JButton class has a doClick method for that purpose

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.