how open image with url in javafx


I have banner an I wont to put it in my javaFX application. And when user click on the image open default browser.

try {
            String path = "";
            URL url = new URL(path);
            BufferedImage image =;
            label = new JLabel(new ImageIcon(image));

        } catch (Exception exp) {

also I am trying to convert above code from awt in JavaFX

11/17/2014 1:32:33 PM

Lets see. First the ingredients:

  1. Image
  2. Button
  3. ImageView
  4. Open Link in System Browser with JavaFX

Putting this together:

String path = "http://...";
String pathToOpen = "http://...";

Image image = new Image(path);
ImageView imageView = new ImageView(image);

Button button = new Button("clickMe!", imageView);
button.setOnAction(ev -> getHostServices().showDocument(pathToOpen));
5/23/2017 12:17:30 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow