[求助]图显示不了?
这是一个简单的画图程序,为什么图现实不了呢?请帮忙,谢谢!import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class shapes extends JPanel
{
public void painComponent(Graphics g)
{
super.paintComponent(g);
g.setColor(Color.blue);
g.drawRect(20,30,100,70);
g.drawLine(180,220,300,270);
g.drawRoundRect(140,40,80,50,15,15);
g.drawOval(30,120,100,40);
Polygon p = new Polygon();
p.addPoint(320,320);
p.addPoint(320,390);
p.addPoint(400,400);
g.drawPolygon(p);
g.setColor(Color.orange);
g.fillRect(320,30,100,70);
g.fillRoundRect(70,220,80,50,15,15);
g.fill3DRect(120,300,100,30,true);
for(int i=1;i<=7;i++)
g.draw3DRect(120-i,300-i,100+2*(i-1),30+2*(i-1),true);
g.fill3DRect(120,370,100,30,false);
for(int i=1;i<=7;i++)
g.draw3DRect(120-i,370-i,100+2*(i-1),30+2*(i-1),true);
g.fillOval(200,130,100,40);
}
}
class Fra extends JFrame
{
public Fra()
{
setTitle("Drawing shapes");
setSize(500,500);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
);
Container con=getContentPane();
con.add(new shapes());
}
}
public class Diagram
{
public static void main(String args[])
{
JFrame fr = new Fra();
fr.setVisible(true);
}
}
[此贴子已经被作者于2007-9-15 19:07:53编辑过]