Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

FileChooser something is wrong with the path Input Stream must not be null

dscarminiabielefeldMar 14 2013 — edited Mar 15 2013
Hi,
im testing the filechooser at the moment.
this is what i got:
                FileChooser fileChooser = new FileChooser();
                FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("PNG files (*.png)", "*.png");
                fileChooser.getExtensionFilters().add(extFilter);

                file = fileChooser.showOpenDialog(null);

                iv.setImage(new javafx.scene.image.Image(getClass().getResourceAsStream(file.getPath())));
gettin:
java.lang.NullPointerException: Input stream must not be null
file.getAbsolutPath() doesn't work either, i thought this was the reason.
what am i doing wrong here?
p.png = picture in the filechooser package.
 
iv.setImage(new javafx.scene.image.Image(getClass().getResourceAsStream(p.png)));
works fine.
Thanks for the help.
im using windows.
This post has been answered by jsmith on Mar 14 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 12 2013
Added on Mar 14 2013
2 comments
1,733 views