4
I want to change the title bar icon of the Java window, as shown below:
I’m going the method initComponents()
and leaving as it is in the code below, but the line setIconImage(iconeTitulo);
is left as a mistake.
public FrmConfiguracoes() {
initComponents();
URL caminhoImagem = this.getClass().getClassLoader().getResource("smile.png");
Image iconeTitulo = Toolkit.getDefaultToolkit().getImage(caminhoImagem);
setIconImage(iconeTitulo);
}
It does not recognize the command and does not change the icon. What can I do? And how to change the logo that is in the minimized icon?
Thanks for the help. You are giving error. I used the code below: //changing logo URL pathImage = this.getClass(). getResource("/logo.bmp"); Image iconeTitulo = Toolkit.getDefaultToolkit(). getImage(pathImage); setIconImage(iconeTitulo); When running the program the error is given: Uncaught error fetching image: java.lang.Nullrepointexception
– Rodrigo Storti de Oliveira
If I am not mistaken it has to be png or jpg the format, and this bar ai is unnecessary if the image is in the same package as the class.
– user28595
@Rodrigostortideoliveira the above code solved the problem?
– user28595
Thanks for the help. I tested with JPG without the bar but it didn’t work
– Rodrigo Storti de Oliveira
@Rodrigostortideoliveira then the problem is with the path. If you’re using netbeans, drag the photo to the same package as your screen class, and just pass the name.extensao.
– user28595