[英]Why can't I set content to my returned object (Java)?
I'm trying to call a drawable spectrum from my controller, then set the following data to it. 我正在尝试从控制器调用可绘制频谱,然后将以下数据设置为可绘制频谱。 I keep getting an error that the left side must be a variable.
我不断收到一个错误,认为左侧必须是变量。 The call is getting a
specPanel(JPanel)
which has a DrawableSpectrum
assigned to it. 调用获取一个
specPanel(JPanel)
,该对象已分配了DrawableSpectrum
。 SpecPanel
has a method called get Spectrum which returns this spectrum. SpecPanel
有一个称为get Spectrum的方法,该方法返回此光谱。 In both of these call I put a System.out.println
if they are not null, and they never are. 在这两个调用中,如果它们不为null,而从未为null,则放入
System.out.println
。
Am I missing something here? 我在这里想念什么吗?
con.getSpecPanel().getSpectrum() = (DrawableSpectrum)interpreter.getShapes().get(0);
Thanks. 谢谢。
You should use Spectrum
's setter instead, assuming you have one. 假设您有一个,则应改用
Spectrum
的二传手。 If you don't you should implement it and then you can set the data like this: 如果不这样做,则应该实现它,然后可以像这样设置数据:
con.getSpecPanel().setSpectrum((DrawableSpectrum)interpreter.getShapes().get(0));
Assignations can be made on fields and variables, that's what the setter does under the hood. 可以在字段和变量上进行分配,这是设置员在后台执行的操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.