这样就行了:import java.awt.*; 
import java.awt.event.*; 
import javax.swing.*; 
/******************************************************************/ 
class DrawPolyPanel extends JPanel 

public void paint(Graphics g) 

super.paintComponent(g); 
int r=40; 
int cx=50; 
int cy=100; 
int angle=30; int dx=(int)(r*Math.cos(angle*Math.PI/180)); 
int dy=(int)(r*Math.sin(angle*Math.PI/180)); g.drawLine(cx,cy,cx+dx,cy+dy); 
g.drawLine(cy,cy,cx+dx,cy-dy); 
g.drawArc(cx-r,cy-r,2*r,2*r,angle,360-2*angle); Polygon p=new Polygon(); 
cx=150; 
int i; 
for(i=0;i<5;i++) 

p.addPoint((int)(cx+r*Math.cos(i*2*Math.PI/5)),(int)(cy+r*Math.sin(i*2*Math.PI/5))); 

g.setColor(Color.red); 
g.drawPolygon(p); Polygon s=new Polygon(); 
cx=250; 
for(i=0;i<360;i++) 

s.addPoint((int)(cx+r*Math.cos(i*8*Math.PI/5)),(int)(cy+r*Math.sin(i*8*Math.PI/5))); 

g.drawPolygon(s); 


/******************************************************************/ 
class DrawPolyFrame extends JFrame 

public DrawPolyFrame() 

setTitle("songyujuan"); 
setSize(600,400); 
addWindowListener(new WindowAdapter() 

public void windowClosing(WindowEvent e) 

System.exit(0); 

}); 
Container contentPane=getContentPane(); 
contentPane.add(new DrawPolyPanel()); 


/******************************************************************/ 
public class DrawPoly 

public static void main(String [] args) 

JFrame frame =new DrawPolyFrame(); 
frame.setBackground(Color.white); 
frame.show(); 


/******************************************************************/