URL url; try { url = new URL(fileName); image = ImageIO.read(url); imageIcon = new ImageIcon(image); } catch (Exception e) { System.out.println(e); } }