想用linkedlist加入几个对象 不知道哪里错了
求大神指点
代码如下
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.LinkedList;
public class TestLinkedList
{
public static void main(String args[])
{
}
}
class Game extends JFrame
{
Body body = null;
public Game()
{
body = new Body();
this.add(body);
this.setSize(300,300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
}
class Body extends JPanel
{
LinkedList<Part> link = new LinkedList<Part>();
Part part[] = new Part[3];
part[0] = new Part();
part[1] = new Part();
part[2] = new Part();
link.add(part[0]);
link.add(part[1]);
link.add(part[2]);
public void paint(Graphics g)
{
super.paint(g);
g.setColor(Color.red);
g.fill3DRect(100,100,30,30,false);
}
}
class Part
{
}
|