import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ButtonHandler extends JFrame implements ActionListener
{
public ButtonHandler()
   {
   JButton exitButton = new JButton("Exit");
   JButton stayButton = new JButton("Stay");
   setLayout( new FlowLayout());

   exitButton.addActionListener( this );
   add(exitButton);
   stayButton.addActionListener( this );
   add(stayButton); 
    
   setSize( 400, 400 );
   setDefaultCloseOperation( EXIT_ON_CLOSE );
   setVisible( true );
   }
public void actionPerformed( ActionEvent e )
   {
   if ( e.getActionCommand() == "Exit" )
      {
      System.out.println("Exit button action...");
      System.exit( 0 );
      } // end if
   if ( e.getActionCommand() == "Stay" )
      {
      System.out.println("Stay button action...");
      } // end if
		
   }  // end method
public static void main(String args [])
   {
   new ButtonHandler();
   }
} // end class