reset password
Author Message
dliang
Posts: 35
Posted 00:53 Feb 02, 2020 |

Question for anyone

Anyone working on the JavaFX GUI now? I tried to used the FileChooser technique and the new library method(the one that Keenan gave us), to convert ppm into an object, then the object will be passed to the SwingFXUtils.toFXImage(), helps me to convert to a regular image. However, there are only two results appear in my scene. Either Java.lang.NullPointerException or no exception with an empty scene.

240812281
Posts: 7
Posted 01:29 Feb 02, 2020 |

NullPointerException means you have not chosen anything so it appears a null value which may cause by the file chooser.

For an empty scene, might be your method only reads the file but not display the image. If you used the code from Keenan, you are supposed to see the image because I can see the image on the scene when I used the code from Keenan.

kknaur
Posts: 540
Posted 11:08 Feb 02, 2020 |

Are you trying with one of the original images or with an image you have edited? 

If its an original image something is wrong with your sequence of steps.  Once you get a JavaFX Image object, you need to put it into an ImageView in order to show it.  It then has to go in a scene, then a stage, then show.

If you are trying to display an image you have edited, and then saved, you may have an issue in your read / write method.  Write the image to a file and then open it with Irfanview to make sure that you wrote the image correctly.  

And yes, if you are getting a NullPointerException, you do not actually have an object in memory and the variable has a null value.