import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class EventDemoLocal{

   protected JButton b;

   public EventDemoLocal(){
      JFrame frame = new JFrame("Event Demo");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.getContentPane().setPreferredSize(new Dimension(200, 200));

      // initialize the button
      b = new JButton("Click me!");
      // add event handling to the button
      b.addActionListener(new ActionListener(){
         public void actionPerformed(ActionEvent e){
            b.setText("Thanks!");
         }
      });

      frame.getContentPane().add(b);

      frame.pack();
      frame.setVisible(true);
   }


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