pliz help finish with task two
Code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class OverlappingCircles extends JFrame implements ActionListener
{
	JButton btnExit=new JButton("Exit");
	JButton btnCreate=new JButton("Create");
	int flag=0;


	public OverlappingCircles()
	{
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setSize(600,600);
		setTitle("Overlapping Circles");
		Container con=getContentPane();
		flag=1;
		setContentPane(con);
		con.setLayout(new BorderLayout());
		btnCreate.addActionListener(this);
		btnExit.addActionListener(this);

		con.add(btnCreate,"North");
		con.add(btnExit,"South");

	}
	public static void main(String[] args)
	{
		OverlappingCircles x=new OverlappingCircles();
		x.setVisible(true);
	}
	public void actionPerformed(ActionEvent e)
	{
		if (e.getSource()==btnCreate)
		{
			repaint();
		}
		else if(e.getSource()==btnExit)
		{
			flag=2;
			repaint();
		}
	}
	public void paint(Graphics g)
	{
		if (flag==1)
		{
			int x1=Math.round((int)(Math.random()*600));
			int x2=Math.round((int)(Math.random()*600));
			int y1=Math.round((int)(Math.random()*400));
			int y2=Math.round((int)(Math.random()*400));
			g.drawOval(x1,y1,100,100);
			g.drawOval(x2,y2,100,100);
			//code to count and produce sound
		}
	}

}

Last edited by shabbir; 19Oct2006 at 14:50.. Reason: Code formating.