import java.awt.*;
import java.awt.event.*;public class MyApp extends Frame
{
public MyApp()
{
   Button b = new Button("AAAAAAAA");
   setLayout(new FlowLayout());
   add(b);
   b.addActionListener(new ActionListener()
       {
          public void actionPerformed(ActionEvent e) 
          {
             MyApp m = new MyApp();
                m.setSize(100,100);
                m.show();
          }
        
       }); 

this.addWindowListener (new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
dispose();
System.exit(0);
}
});
}

public static void main(String args[])
{
      MyApp m = new MyApp();
      m.setSize(400,400);
      m.show();

}
}v