java - Cannot load image in JavaFX -


i tested code in order create dialog image.

final int xsize = 400; final int ysize = 280; final color backgroundcolor = color.white; final string text = "sql browser"; final string version = "product version: 1.0";  final stage aboutdialog = new stage(); aboutdialog.initmodality(modality.window_modal);  button closebutton = new button("close");  closebutton.setonaction(new eventhandler<actionevent>() {     @override     public void handle(actionevent arg0) {         aboutdialog.close();     } });  gridpane grid = new gridpane(); grid.setalignment(pos.center); grid.sethgap(10); grid.setvgap(10); grid.setpadding(new insets(25, 25, 25, 25));  image img = new image("logo.png"); imageview imgview = new imageview(img);  grid.add(imgview, 0, 0);  grid.add(new text(text), 0, 1); grid.add(new text(version), 0, 2); grid.add(closebutton, 14, 18);  scene aboutdialogscene = new scene(grid, xsize, ysize, backgroundcolor); aboutdialog.setscene(aboutdialogscene); aboutdialog.show(); 

i placed image file directory /src. reason image not displayed. can me correct mistake?

simply replace code:

image img = new image("logo.png"); 

with this

image img = new image("file:logo.png"); 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -