下面应用程序,绘制一个红色五角星,请完成程序。
import java.awt.*;
import Javax.swing.*;
class MyPanel extends JPanel
public void______
int r=100;
int x1=100,
x2=(int)(r*(1-Math.cos((18*Math. PI)/180))),
x3=(int)(r*(1+Math.cos((18*Math. PI)/180))),
x4=(int)(r*(1-Math.cos((54*Math. PI)/180))),
x5=(int)(r*(1+Math.cos((54*Math. PI)/180))),
y1=0,
y2=(int)(r*(1-Math.sin((18*Math. PI)/180))),
y3=(int)(r*(1-Math.sin((18*Math. PI)/180))),
y4=(int)(r*(1+Math.sin((54*Math.PI)/180))).
y5=(int)(r*(1+Math.sin((54*Math. PI)/180)));
______
g.drawOval(0,0,200,200);
g.drawLine(x4,y4,x1,y1);g.drawLine(x1,y1,x5,y5);
g.drawLine(x5,y5,x2,y2);g.drawLine(x2,y2,x3,y3);
g.drawLine(x3,y3,x4,y4);
public class C3002 extends JFrame
C3002()
super("C3002");
setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE);
getContentPane().add(new MyPanel());
setSize(210,242);
setVisible(true);
public static void main(String[] args)
new C3002();
参考答案:paintComponent(Graphics g)
g. setColor(Color. RED);