2

I am a newbie in JavaFX and I try by clicking on one imageview (ImageView1)get its image and set another imageview (ImageView2) with that image.

BufferedImage actualBufferedImage= SwingFXUtils.fromFXImage(ImageView1.getImage(), null);
WritableImage actualImage= SwingFXUtils.toFXImage(image, null);
ImageView2.setImage(actualImage);

But I got NullPointerException. This exception happens in setImage line. I can not find out why actualImage is null after toFXIamge.

ShrnPrmshr
  • 353
  • 2
  • 5
  • 17
  • If `ImageView2.setImage(actualImage)` is throwing a null pointer exception, then `ImageView2` is null. – James_D Jul 23 '17 at 18:12
  • Thanks for your quick answer. Actually ImageView2 is in another controller. and I try by one class in model access to it. Maybe there is a chance that controller has not yet initialized. so imageView2 is null. – ShrnPrmshr Jul 23 '17 at 19:18

0 Answers0