Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+26 votes

So, Json stuff.
We can save the json file,
but there is an error when we try to load it.

If we added a point or set the path to the chick and save to JSON file,
ERROR~~~

If we didn't add a point or didn't set the path to the chick and save to JSON file,
No error.

Here is error messages

java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to javafx.graphics@10.0.2/com.sun.prism.paint.Paint

at javafx.graphics/com.sun.javafx.sg.prism.NGCanvas.renderStream(Unknown Source)
at javafx.graphics/com.sun.javafx.sg.prism.NGCanvas.renderContent(Unknown Source)
at javafx.graphics/com.sun.javafx.sg.prism.NGNode.doRender(Unknown Source)

......

Please, respond as soon as possible, HQ

asked in CSC285_Fall2018 by (1 point)
edited by
+5

Take me home~ Country road~
I wanna go home. Plz
I have stuck in the computer lab for ... I forgot.

3 Answers

+11 votes
 
Best answer

Also having the same issue...

answered by (1 point)
selected by
+9 votes

It sounds like you've got a data field inside one of your data model classes that is of a type that GSON doesn't serialize very well. From your error message, probably a JavaFX object of some kind.

Maybe Color objects aren't well supported by GSON? Not sure.

Instead of storing a javafx.scene.paint.Color object directly inside of AnimalTrack, you could consider storing a String field that will represent the Color.

To convert a JavaFX color into a string, you can use:

https://docs.oracle.com/javafx/2/api/javafx/scene/paint/Color.html#web(java.lang.String)

And then you can provide a getter method that still gets the Color object, by using Color.valueOf(colorString)

https://docs.oracle.com/javafx/2/api/javafx/scene/paint/Color.html#valueOf(java.lang.String)

answered by (4k points)
+8 votes

My group has problem with that one too, when we do something with that window, it just cannot load, but when we do nothing, it work.

answered by (1 point)
...