Line是我写的类,我也把它们放在同一个包里面了,就是出错,而且都类似 该怎么办啊virtualplatform.java:1114annot resolve symbol symbol : class VoltageMeter location: class shiyan.VirtualPlatform l=new VoltageMeter(++UnitId); ^virtualplatform.java:1085nnot resolve symbol symbol : class Battery location: class shiyan.VirtualPlatform b=(Battery)eb.nextElement(); ^......
package shiyan;import java.awt.*; import java.util.*; public class VirtualPlatform extends Panel { public int UnitId=0; private int num; //record the type of mouse' moving unit private int prex,prey; //record the prepoint of x and y of mouse'moving private VirtualLab virtualLab; public Vector vbattery=new Vector(); public Vector vvoltageMeter=new Vector(); public Vector vcarrentMeter=new Vector(); public Vector velectricLight=new Vector(); public Vector vresistance=new Vector(); public Vector vline=new Vector(); public VirtualPlatform(VirtualLab virtualLab) { this.virtualLab=virtualLab; this.setBackground(new Color(200,240,200)); } private Battery pickBattery1,pickBattery2; private VoltageMeter pickVoltageMeter1,pickVoltageMeter2; private CarrentMeter pickCarrentMeter1,pickCarrentMeter2; private ElectricLight pickElectricLight1,pickElectricLight2; private Resistance pickResistance1,pickResistance2; private Line l; private int pickUnit; //pick the number of unit private int from,to; private int fromxLeft,fromxRight,fromy; private int toxLeft,toxRight,tox,toy; public boolean controlLine=false; //private boolean pickFixed; private Image offScreen; private Dimension offScreenSize; private Graphics offGraphics; public synchronized void paint(Graphics g) { Dimension d=size(); if((offScreen==null)||(d.width!=offScreenSize.width)||(d.height!=offScreenSize.height)) { offScreen=createImage(d.width,d.height); offScreenSize=d; offGraphics=offScreen.getGraphics(); } offGraphics.setColor(Color.black); offGraphics.drawRect(0,0,d.width-1,d.height-1); //update(offGraphics); if(pickUnit==1) { if(fromxRight!=0) { offGraphics.drawLine(fromxRight,fromy,tox,toy); } else if(fromxLeft!=0) { offGraphics.drawLine(fromxLeft,fromy,tox,toy); } } if(pickUnit==2) { Line l=new Line(++UnitId); //这里就出错了 .... } Battery b; //这里就出错了 for(Enumeration eb=vbattery.elements();eb.hasMoreElements();) { b=(Battery)eb.nextElement(); b.paint(offGraphics); } VoltageMeter v; //这里就出错了 for(Enumeration ev=vvoltageMeter.elements();ev.hasMoreElements();) { v=(VoltageMeter)ev.nextElement(); v.paint(offGraphics); } CarrentMeter c; //这里就出错了 for(Enumeration ec=vcarrentMeter.elements();ec.hasMoreElements();) { c=(CarrentMeter)ec.nextElement(); c.paint(offGraphics); } ElectricLight e; //这里就出错了 for(Enumeration ee=velectricLight.elements();ee.hasMoreElements();) { e=(ElectricLight)ee.nextElement(); offGraphics.setColor(new Color(e.color,0,0)); e.paint(offGraphics); offGraphics.setColor(Color.black); } Resistance r; //这里就出错了 for(Enumeration er=vresistance.elements();er.hasMoreElements();) { r=(Resistance)er.nextElement(); r.paint(offGraphics); } Line l; //这里就出错了 for(Enumeration el=vline.elements();el.hasMoreElements();) { l=(Line)el.nextElement(); l.paint(offGraphics); } g.drawImage(offScreen,0,0,null); } public synchronized boolean mouseDown(Event evt,int x,int y) { update(offGraphics); if(controlLine==true) { for(Enumeration eb=vbattery.elements();eb.hasMoreElements();) { Battery b=(Battery)eb.nextElement(); //这里就出错了 ...... } for(Enumeration ev=vvoltageMeter.elements();ev.hasMoreElements();) { VoltageMeter v=(VoltageMeter)ev.nextElement(); //这里就出错了 , 以下是一些计算的式子,错的方式都差不多 if((x>v.x+10&&x<v.x+29+10)&&(y>v.y&&y<v.y+21)) { pickVoltageMeter1=v; from=pickVoltageMeter1.id; if(x<pickVoltageMeter1.x+14+10) fromxLeft=pickVoltageMeter1.x+10; else fromxRight=pickVoltageMeter1.x+29+10; fromy=pickVoltageMeter1.y+10; pickUnit=1; return true; } } } for(Enumeration eb=vbattery.elements();eb.hasMoreElements();) { Battery b=(Battery)eb.nextElement(); //这里就出错了 if((x>b.x&&x<b.x+27)&&(y>b.y&&y<b.y+21)) { num=1; pickBattery1=b; prex=x-b.x; prey=y-b.y; return true; } ....... } } ..... }
该怎么办啊virtualplatform.java:1114annot resolve symbol
symbol : class VoltageMeter
location: class shiyan.VirtualPlatform
l=new VoltageMeter(++UnitId);
^virtualplatform.java:1085nnot resolve symbol
symbol : class Battery
location: class shiyan.VirtualPlatform
b=(Battery)eb.nextElement();
^......
import java.util.*;
public class VirtualPlatform extends Panel
{
public int UnitId=0; private int num; //record the type of mouse' moving unit
private int prex,prey; //record the prepoint of x and y of mouse'moving
private VirtualLab virtualLab; public Vector vbattery=new Vector();
public Vector vvoltageMeter=new Vector();
public Vector vcarrentMeter=new Vector();
public Vector velectricLight=new Vector();
public Vector vresistance=new Vector();
public Vector vline=new Vector(); public VirtualPlatform(VirtualLab virtualLab)
{
this.virtualLab=virtualLab;
this.setBackground(new Color(200,240,200)); } private Battery pickBattery1,pickBattery2;
private VoltageMeter pickVoltageMeter1,pickVoltageMeter2;
private CarrentMeter pickCarrentMeter1,pickCarrentMeter2;
private ElectricLight pickElectricLight1,pickElectricLight2;
private Resistance pickResistance1,pickResistance2; private Line l;
private int pickUnit; //pick the number of unit
private int from,to;
private int fromxLeft,fromxRight,fromy;
private int toxLeft,toxRight,tox,toy;
public boolean controlLine=false; //private boolean pickFixed;
private Image offScreen;
private Dimension offScreenSize;
private Graphics offGraphics; public synchronized void paint(Graphics g)
{ Dimension d=size();
if((offScreen==null)||(d.width!=offScreenSize.width)||(d.height!=offScreenSize.height))
{
offScreen=createImage(d.width,d.height);
offScreenSize=d;
offGraphics=offScreen.getGraphics();
} offGraphics.setColor(Color.black);
offGraphics.drawRect(0,0,d.width-1,d.height-1);
//update(offGraphics);
if(pickUnit==1)
{
if(fromxRight!=0)
{ offGraphics.drawLine(fromxRight,fromy,tox,toy); }
else if(fromxLeft!=0)
{ offGraphics.drawLine(fromxLeft,fromy,tox,toy); }
} if(pickUnit==2)
{
Line l=new Line(++UnitId); //这里就出错了
.... }
Battery b; //这里就出错了
for(Enumeration eb=vbattery.elements();eb.hasMoreElements();)
{
b=(Battery)eb.nextElement();
b.paint(offGraphics);
} VoltageMeter v; //这里就出错了
for(Enumeration ev=vvoltageMeter.elements();ev.hasMoreElements();)
{
v=(VoltageMeter)ev.nextElement();
v.paint(offGraphics);
} CarrentMeter c; //这里就出错了
for(Enumeration ec=vcarrentMeter.elements();ec.hasMoreElements();)
{
c=(CarrentMeter)ec.nextElement();
c.paint(offGraphics);
} ElectricLight e; //这里就出错了
for(Enumeration ee=velectricLight.elements();ee.hasMoreElements();)
{
e=(ElectricLight)ee.nextElement();
offGraphics.setColor(new Color(e.color,0,0));
e.paint(offGraphics);
offGraphics.setColor(Color.black);
} Resistance r; //这里就出错了
for(Enumeration er=vresistance.elements();er.hasMoreElements();)
{
r=(Resistance)er.nextElement();
r.paint(offGraphics);
} Line l; //这里就出错了
for(Enumeration el=vline.elements();el.hasMoreElements();)
{
l=(Line)el.nextElement();
l.paint(offGraphics);
}
g.drawImage(offScreen,0,0,null); } public synchronized boolean mouseDown(Event evt,int x,int y)
{ update(offGraphics);
if(controlLine==true)
{ for(Enumeration eb=vbattery.elements();eb.hasMoreElements();)
{
Battery b=(Battery)eb.nextElement(); //这里就出错了
...... } for(Enumeration ev=vvoltageMeter.elements();ev.hasMoreElements();)
{
VoltageMeter v=(VoltageMeter)ev.nextElement(); //这里就出错了 , 以下是一些计算的式子,错的方式都差不多
if((x>v.x+10&&x<v.x+29+10)&&(y>v.y&&y<v.y+21))
{ pickVoltageMeter1=v;
from=pickVoltageMeter1.id;
if(x<pickVoltageMeter1.x+14+10)
fromxLeft=pickVoltageMeter1.x+10;
else
fromxRight=pickVoltageMeter1.x+29+10;
fromy=pickVoltageMeter1.y+10; pickUnit=1;
return true;
} }
} for(Enumeration eb=vbattery.elements();eb.hasMoreElements();)
{
Battery b=(Battery)eb.nextElement(); //这里就出错了
if((x>b.x&&x<b.x+27)&&(y>b.y&&y<b.y+21))
{
num=1;
pickBattery1=b;
prex=x-b.x;
prey=y-b.y;
return true;
}
.......
}
}
.....
}