By icon in JFrame

3

Would it be possible for icons in the executable application via code?

    
asked by anonymous 02.06.2017 / 22:47

1 answer

3

Yes, it is possible:

URL iconURL = getClass().getResource("/some/package/favicon.png") ;

ImageIcon icon = new ImageIcon(iconURL);
frame.setIconImage(icon.getImage());

Or by creating a type Imagem through the class ImageIO , added in java-7:

Image imagem = ImageIO.read(getClass().getResource("/some/package/favicon.png"));

frame.setIconImage(imagem);

Source: How to set Icon to JFrame

    
02.06.2017 / 22:48