Steps to Implement EventListener Applet
The folder view of the project is shown in the below image.
Step 1: We need to check the Java version by running the below command in the terminal:
Step 2: First, create the file as ListenerApplet.java and enter the code into it.
Step 3: Once the code is been inserted then we need to create the ListenerApplet.html file, through which we will display the output.
HTML
<!DOCTYPE html> < html > < head > < title >Listener Applet</ title > </ head > < body > < applet code = "ListenerApplet.class" width = "300" height = "300" > </ applet > </ body > </ html > |
Step 4: Then we need to compile the Java code using the below command. We can see that the new .class file is been generated.
javac ListenerApplet.java
Step 5: Now finally we need to run the application using the below command:
appletviewer ListenerApplet.html
How to Create an Event Listener in Applet?
In this article, we will be creating the event Listener in the Applet window. Here, we will use the ActionListener on Button and MouseListener when the event has occurred through mouse activities.