+ -
当前位置:首页 → 问答吧 → 如何修改其他类的内部类的值

如何修改其他类的内部类的值

时间:2011-09-25

来源:互联网

有三个类 ,
一个类是A 一个类B,一个类C ,C为B的内部类
请问类A的鼠标事件
if(e.getSource()==PG){  
内容
}

如何修改类B(Shape)里的内部类C的一个变量(playcheck)的值?

我用
public Shape.ShapeDriver shapedriver;
shapedriver =new Shape.ShapeDriver(); //new Shape.ShapeDriver()出现错误
错误提示(No enclosing instance of type Shape is accessible. Must qualify the allocation with an enclosing instance of type Shape (e.g. x.new A() where x is an instance of Shape).)

shapedriver.playcheck +=1;

求解 。

作者: prince502143585   发布时间: 2011-09-25

你把代码贴出来,帮你改好就给贴上

你这么说我们也没法告诉你怎么做,而且跟你说了你估计也未必完全理解

作者: ioe_gaoyong   发布时间: 2011-09-25

如果你的A类里面有C类引用,那么在C类里面定义一个引用,让B类里面那个值指向C类的引用!
  这样,A类里面操作C类里面的那个引用,B类就能改变了,不知道这个思路对不对!
也没看到你的代码!

作者: baillluu   发布时间: 2011-09-25

热门下载

更多