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

public class lez20070622 extends JPanel implements Runnable
{
	Thread t;
	double x, y, angle, time;
	boolean acceso = false;
	
	public lez20070622()
	{
		t = new Thread(this);
		t.start();
	}
	
	public void run()
	{
		while(t != null)
		{
			angle+=0.1;
//			time+=0.1;
//			if (time >= 3.0) 
//			{ 
//				time = 0; 
//				acceso = !acceso;
//			}
			x = Math.cos(angle/10)*Math.min(this.getWidth(), this.getHeight())/2 + this.getWidth()/2;
			y = Math.sin(angle/10)*Math.min(this.getWidth(), this.getHeight())/2 + this.getHeight()/2;
			repaint();
			try {t.sleep(10); } catch (InterruptedException e){ System.out.println(e.toString());}
		}
	}
	
	public void paint(Graphics s)
	{
		super.paintComponent(s);
		s.setColor(Color.black);
		s.fillRect(0,0,this.getWidth(),this.getHeight());
		s.setColor(Color.green);
		s.drawLine(this.getWidth()/2, this.getHeight()/2, (int)x, (int)y);
		if (acceso) s.setColor(Color.blue); else s.setColor(Color.green);
		s.fillOval((int)x - 15, (int)y - 15, 30, 30);
	}

	public static void main(String[] a){
		JFrame f = new JFrame();
		f.setTitle("asd");
		f.setSize(400,400);
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		f.getContentPane().add(new lez20070622());
		f.setVisible(true);
	}
}

