Event Handling using Anonymous Class in Applet

Author posted by Jitendra on Posted on under category Categories JAVA and tagged as Tags , , with Leave a comment on Event Handling using Anonymous Class in Applet

Source code to demonstrate the usage of anonymous class in Applet

We can handle the Event in Applet, AWT or Swing by following three different methods:

  • Inner Class
  • Anonymous class
  • this Pointer

In this example, i will show you that how to use Anonymous classes to handle the events in Applet.

package com.kunal.applet;

import java.applet.Applet;
import java.awt.Button;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class AnonymouseButton extends Applet {

  TextField txtSource;
  Button btnToLOwer;

  public void init()
     txtSource=new TextField(20);
     btnToLOwer=new Button("Lower Case");
     btnToLOwer.addActionListener(new ActionListener(){

       public void actionPerformed(ActionEvent e) {

       String tmp=txtSource.getText();



Event Handling using Anonymous Class in Applet

Related posts

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.