0

I want to put an Image into a GridPane.

The URI ist existant, I imported javafx.scene.image, I declared everything. Why does it not work? It just gives me a blank window. Even with a local picture its not working. And when I for example write something like "file:sdhasidf.png" (Not existant btw.), its just a blank window, too. I'm just getting a UnknownProtocol Exception if I mess up the protocol, so it gets loaded.

Image img = new Image("https://cdn.discordapp.com/attachments/250163910454280192/296377451599364107/Untitled.png");
ImageView imgView = new ImageView(img);

GridPane.setConstraints(imgView, 5, 0);
gp.getChildren().add(imgView);  //gp ist a GridPane

Scene scene = new Scene(gp, 500, 600);
window.setScene(scene);
window.show();

Thanks for reading :)

Reisbrot
  • 37
  • 9
  • I took your code and used '"http://mikecann.co.uk/wp-content/uploads/2009/12/javafx_logo_color_1.jpg' and it worked with no problem. I am guessing maybe https is the problem or the picture's file permissions. – SedJ601 Apr 06 '17 at 13:39
  • @SedrickJefferson I guessed there should be a FilePermissonException if its that – Reisbrot Apr 06 '17 at 14:38
  • Did you try it with the link I provided to see if it would work. – SedJ601 Apr 06 '17 at 14:44
  • Oh, well it does function, but my button will vanish D: Whats the solution for FilePermission :c – Reisbrot Apr 07 '17 at 17:39
  • I just posted a question about your situation [here](https://stackoverflow.com/questions/43285033/how-to-load-images-from-url-in-javafx#) and it seems that the problem is a HTTP 403 error. You can research it on Wikipedia. – SedJ601 Apr 07 '17 at 19:19
  • I said it works well – Reisbrot Apr 07 '17 at 19:33

0 Answers0