public static ImageView asImageViewFX(ImageIcon imageIcon){
  java.awt.Image awtImage=imageIcon.getImage();
  if (awtImage != null) {
    final BufferedImage bImg;
    if (awtImage instanceof BufferedImage) {
      bImg=(BufferedImage)awtImage;
    }
 else {
      bImg=new BufferedImage(awtImage.getWidth(null),awtImage.getHeight(null),BufferedImage.TYPE_INT_ARGB);
      Graphics2D graphics=bImg.createGraphics();
      graphics.drawImage(awtImage,0,0,null);
      graphics.dispose();
    }
    return new ImageView(SwingFXUtils.toFXImage(bImg,null));
  }
 else   return null;
}

public static ImageView asImageViewFX ( ImageIcon imageIcon ) { java . awt . Image awtImage = imageIcon . getImage ( ) ; if ( awtImage != null ) { final BufferedImage bImg ; if ( awtImage instanceof BufferedImage ) { bImg = ( BufferedImage ) awtImage ; } else { bImg = new BufferedImage ( awtImage . getWidth ( null ) , awtImage . getHeight ( null ) , BufferedImage . TYPE_INT_ARGB ) ; Graphics2D graphics = bImg . createGraphics ( ) ; graphics . drawImage ( awtImage , 0 , 0 , null ) ; graphics . dispose ( ) ; } return new ImageView ( SwingFXUtils . toFXImage ( bImg , null ) ) ; } else return null ; }
convert awt imageicon to javafx image
