Event Handling Program in Java

Class: BCA IIyr
Subject: Internet Application using JAVA
Subject type:Minor

import java.awt.*;
import java.awt.event.*;

class Demo extends Frame implements ActionListener {

    Button b;

    Demo()
{
        b = new Button("Click");
        b.addActionListener(this); // event delegation
        add(b);
        setSize(200, 150);
        setVisible(true);
    }

   public void actionPerformed(ActionEvent e)
{
       System.out.println("wel come");
    }

    public static void main(String[] args) {
        new Demo();
    }
}



0 comments:

Post a Comment