import java.awt.*; import java.awt.event.*; public class MySecondGUI extends Frame { Button close; public MySecondGUI() { this("My Second GUI"); } public MySecondGUI(String title) { super(title); setLayout(new BorderLayout()); add("North",new Label("*yaaaawnnnn*")); add("Center",new Button("push me?")); add("West",new Scrollbar(Scrollbar.VERTICAL)); close=new Button("close"); close.addActionListener( new myActionListener(this)); add("South",close); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { dispose(); //e.getWindow().dispose(); System.exit(0); } }); pack(); show(); } public static void main(String args[]) { if (args.length>0) new MySecondGUI(args[0]); else new MySecondGUI(); } } class myActionListener implements ActionListener{ MySecondGUI mygui; public myActionListener(MySecondGUI mygui) { this.mygui=mygui; } public void actionPerformed(ActionEvent e) { mygui.close.setLabel("try again?"); } }