You are on page 1of 1

import java.awt.

*;
import java.awt.event.*;
import javax.swing.*;
class AwtEventDemo extends Frame implements ActionListener{
AwtEventDemo(){
setSize(300,300);
setLayout(new FlowLayout());
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
System.exit(0);
}
});
//creating object of button component
Button b=new Button("click me");
//registering the component with listener
b.addActionListener(this);
//
add(b);
setVisible(true);
}
public void actionPerformed(ActionEvent ae){
new JOptionPane().showMessageDialog(this,"Welcome to AWT");
}
public static void main(String args[ ]) {
AwtEventDemo f1=new AwtEventDemo();
}
}

You might also like