Sat Apr 07, 2007 8:15 pm
// LineCircle.java
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JFrame;
/**
*
*/
public class LineCircle extends JFrame{
/** Creates a new instance of LineCircle */
private int r=200;
private float theta;
private int width=500;
private int height=500;
private int x=0;
private int y=0;
public LineCircle() {
setTitle("Codemiles");
setSize(width,height);
}
public void paint(Graphics g) {
g.fillRect(0,0,500,500);
g.setColor(Color.RED);
int drawX=0;
int drawY=0;
int color=0;
while(theta<360)
{
g.setColor(new Color(255-color,10+color,color));
drawX=(x+(int)(r*Math.cos(theta)));
drawY=(y+(int)(r*Math.sin(theta)));
g.drawLine(0+250,250-0,drawX+250,250-drawY);
theta+=0.5;
if(theta%2==0)
color++;
}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
LineCircle LC=new LineCircle();
LC.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
LC.setVisible(true);
}
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.