0

I have followed the FX 2 tutorial in order to add a .png image to a button, but I didn't succeed.

The pointer.png is in package icons: in controller class I have try this

@Override
public void initialize(URL url, ResourceBundle rb) {

    Image pointer = new Image(getClass().getResourceAsStream("C:\\Users\\utente\\Desktop\\Java\\NewProjectX\\src\\icons\\Pointer.png"));
    togglebuttonPointer.setGraphic(new ImageView(pointer));

but it doesn't work.

Any help really appreciated.

4

1 回答 1

1

尝试

Image pointer = new Image(getClass().getResourceAsStream("/icons/Pointer.png"));
于 2013-06-18T15:14:47.597 回答