Null Pointer Exception JavaFX

0

What's wrong with the following snippet of my code?

public static void retorna(BufferedImage bufImage) throws IOException {
    // String file = new String("test.png");
    // setTfFoto(bufImage);


    Image image = null;
    SwingFXUtils.toFXImage(bufImage, (WritableImage) image);

    //SwingFXUtils.toFXImage(bufImage, image);

    tfFoto.setImage(image);
    System.out.println("imprimiu a foto na tela");

}

tfFoto is an ImageView created using FXML but I can not in any way receive this BufferedImage from another method and make it appear in my interface.

Could someone help me?

    
asked by anonymous 19.03.2016 / 16:04

1 answer

0
 Image image = null;
SwingFXUtils.toFXImage(bufImage, (WritableImage) image);

You are trying to cast null to WritableImage. For this to work you need to instantiate / inject Image somehow.

    
21.03.2016 / 17:13