其他分享
首页 > 其他分享> > 3、定义MyPanel类

3、定义MyPanel类

作者:互联网

class MyPanel extends JPanel{
MyTank mt;
EnemyTank et;
ArrayList ets=new ArrayList();
int etnum=5;
public void paint(Graphics g){
super.paint(g);
g.fill3DRect(0, 0, 700, 700, false);
for(int i=0;i<ets.size();i++){
et=ets.get(i);
et.paintTank(g);
}
mt.paintTank(g);
}
public MyPanel(){
mt=new MyTank(300,600);
for(int i=0;i<etnum;i++){
et=new EnemyTank(100*(i+1),100);
ets.add(et);
}
}
}

标签:ets,定义,int,mt,new,et,MyPanel
来源: https://www.cnblogs.com/liang-xp/p/11778693.html