ArrayList中的get方法该怎么用?代码如下,谢谢!
CFree 2002-04-21 11:44:19 import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.util.*;
public class WorkFlow extends Applet
{
Graphics g;
int sx,sy,ex,ey;
boolean bCalling,bSelected;
DrawObj firstObj=new DrawObj();
ArrayList CollectionObj=new ArrayList();
public void init()
{
bCalling=false;
bSelected=true;
setBackground(Color.white);
}
public void paint(Graphics g)
{
if (bCalling==true)
{
for (int i=0;i<CollectionObj.size();i++)
{
g.drawRect(CollectionObj.get(i).x-40,CollectionObj.get(i).y-20,80,40);//出错!
}
}
}
public void addDrawObj(int x,int y)
{
firstObj.x=x;
firstObj.y=y;
CollectionObj.add(firstObj);
}
public boolean mouseDown(Event e,int x, int y)
{
bCalling=true;
if (bSelected==true)
{
sx=x;
sy=y;
addDrawObj(x,y);
repaint();
}
return true;
}
}
class DrawObj
{
int x,y;
boolean bIsSelected;
public DrawObj()
{}
}