简体   繁体   中英

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 has a method called get Spectrum which returns this spectrum. In both of these call I put a System.out.println if they are not null, and they never are.

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM