/*
 *  =============================================================
 *  BouncingCircles.java : Extends JApplet and contains a panel where
 *  circles bounce around on the screen. Also contains start and stop
 *  buttons that start circles and stop circles respectively. 
 *
 *  Written by : Vasilios Lagakos                     March, 2001
 *  ==============================================================
 */

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

public class BouncingCircles extends JApplet {
   BouncePanel panel;
   JButton startButton, stopButton;
   

   public void init() {

	Container content = new JPanel(new BorderLayout());
	panel = new BouncePanel();
	content.add(panel, BorderLayout.CENTER);

	startButton = new JButton("Start a circle");
	startButton.addActionListener(new ButtonListener());
	stopButton = new JButton("Stop all circles");
	stopButton.setEnabled(false);
	stopButton.addActionListener(new ButtonListener());
	JPanel p = new JPanel();
	p.add(startButton);
	p.add(stopButton);
	content.add(p, BorderLayout.SOUTH);

	setContentPane(content);

	
   }	

   class ButtonListener implements ActionListener {
	
	public void actionPerformed(ActionEvent e) {
	   if(e.getSource() == startButton){
		stopButton.setEnabled(true);
		panel.start();		
	   }else if (e.getSource() == stopButton) {
		panel.stop();
	   }
	}
   }		


} // end of class BouncingCircles

