/*
 * Copyright (c) 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
 *
 * Permission to use, copy, modify, and distribute this software
 * and its documentation for NON-COMMERCIAL purposes and without
 * fee is hereby granted provided that this copyright notice
 * appears in all copies. Please refer to the file "copyright.html"
 * for further important copyright and licensing information.
 *
 * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
 * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
 * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
 */

/* Modified to be an application on 8/10/99 by J. Walter */

import java.awt.*;
import java.awt.event.*;

public class SpotFrame extends Frame implements MouseListener,
                                  ActionListener {  // necessary due to 
                                                    // added close button
    private java.awt.Point clickPoint = null;
    private static final int RADIUS = 7;
    private Button close;               // new button to close frame

    public SpotFrame() {                // modified init method
      setTitle("SpotFrame");            // now constructor
      setLayout(new FlowLayout());
      addMouseListener(this);
      close = new Button("Exit");
      add(close);
      close.addActionListener(this);
    }
    public void paint(Graphics g) {
	g.drawRect(0, 0, getSize().width - 1,
			 getSize().height - 1);
	if (clickPoint != null)
	    g.fillOval(clickPoint.x - RADIUS,
		       clickPoint.y - RADIUS,
		       RADIUS * 2, RADIUS * 2);
    }
    public void mousePressed(MouseEvent event) {	
	clickPoint = event.getPoint();
	repaint();
    }
    public void mouseClicked(MouseEvent event) {}
    public void mouseReleased(MouseEvent event) {}
    public void mouseEntered(MouseEvent event) {}
    public void mouseExited(MouseEvent event) {}

    public static void main(String[] args) {   // added main method
       SpotFrame f = new SpotFrame();          // create object of type
       f.setSize(500,500);                     // SpotFrame & set size
       f.setVisible(true);
    }

    public void actionPerformed(ActionEvent event) {
       if (event.getSource() == close)    // added method to close
          System.exit(0);                 
       repaint();
    }
}

