get Icon of JavaFX ImageView - Java JavaFX

Java examples for JavaFX:Image

Description

get Icon of JavaFX ImageView

Demo Code


import javafx.scene.image.Image;
import javafx.scene.image.ImageView;

public class Main{
    public static ImageView getIcon(String path, int size) {
        Image icon = new Image(FXUtils.class.getResourceAsStream(path));
        ImageView imageView = new ImageView(icon);
        imageView.setFitWidth(size);/*from  ww w  .j a  v  a  2s.  c  o m*/
        imageView.setFitHeight(size);
        return imageView;
    }
}

Related Tutorials