import java.awt.*;
import java.applet.*;
import java.awt.event.*;
class New_Canvas extends Canvas //New_Canvas繼承Canvas類別
{
New_Canvas()
{
setBackground(Color.white);
setSize(280,280);
}
public void paint(Graphics g) //覆寫paint方法,使其在Canvas上畫圖
{
double x[] = new double[10];
double y[] = new double[10];
double x_cen=140,y_cen=140,dis=100;
int i,j;
for(i=0;i
{
x[i]=x_cen+dis*Math.cos(36*i*Math.PI/180);
y[i]=y_cen+dis*Math.sin(36*i*Math.PI/180);
}
for(i=0;i
{
for(j=0;j
g.drawLine((int)x[i],(int)y[i],(int)x[j],(int)y[j]);
}
}
}
public class Ten extends Applet
{
public void init()
{
New_Canvas canv = new New_Canvas();
add(canv);
}
}
- May 23 Wed 2007 21:39
<Java-基礎>AWT-使用Canvas
close
全站熱搜
留言列表
發表留言