Monday, 26 August 2013

How to Load dynamic image in JavaFx

Use Filechooser for the dialog box and specify the extension which u want to take and load it on to your requirement.      

  FileChooser fileChooser = new FileChooser();
          System.out.print("in browse button handle action event,mouse clicked");
            FileChooser.ExtensionFilter extFilterJPG = new FileChooser.ExtensionFilter("JPG files (*.jpg)", "*.JPG");
           FileChooser.ExtensionFilter extFilterPNG = new FileChooser.ExtensionFilter("PNG files (*.png)", "*.PNG");
           fileChooser.getExtensionFilters().addAll(extFilterJPG, extFilterPNG);
             File file = fileChooser.showOpenDialog(null);
                BufferedImage bufferedImage =;
                WritableImage image = SwingFXUtils.toFXImage(bufferedImage,null);

No comments:

Post a Comment