By icon in Jframe

Asked

Viewed 314 times

3

It would be possible to icons in the application executable through code?

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 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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.