如何修改其他类的内部类的值
时间: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;
求解 。
一个类是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类就能改变了,不知道这个思路对不对!
也没看到你的代码!
这样,A类里面操作C类里面的那个引用,B类就能改变了,不知道这个思路对不对!
也没看到你的代码!
作者: baillluu 发布时间: 2011-09-25
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28