This site requires JavaScript, please enable it in your browser!
Greenfoot back
Gamezocker
Gamezocker wrote ...

2014/2/17

Icon

Gamezocker Gamezocker

2014/2/17

#
Hello, When I export my game as a jar-file and open it. Then I have in the taskbar always such an ugly picture, how can I change the icon?
erdelf erdelf

2014/2/17

#
not possible as far as i know convert it in an executable file (.exe) and then u can change the icon
JetLennit JetLennit

2014/2/17

#
It may not work, but try importing this
1
import greenfoot.core.WorldHandler; 
then add this to your code
1
2
3
JFrame f = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, panel);
ImageIcon img = new ImageIcon(this.getClass().getResource(/*path to image*/));
f.setIconImage(img.getImage());
davmac davmac

2014/2/18

#
It may not work, but try importing this
If you do this, you'd be using internal, undocumented Greenfoot APIs that might change in the future.
Gamezocker Gamezocker

2014/2/18

#
JetLennit wrote...
It may not work, but try importing this
1
import greenfoot.core.WorldHandler; 
then add this to your code
1
2
3
JFrame f = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, panel);
ImageIcon img = new ImageIcon(this.getClass().getResource(/*path to image*/));
f.setIconImage(img.getImage());
i get the error: cannot find symbole - class JFrame
JetLennit JetLennit

2014/2/18

#
Try importing javax.swing.JFrame
Gamezocker Gamezocker

2014/2/18

#
ok, that helps but now i get the error: cannot find symbole - variable panel
JetLennit JetLennit

2014/2/18

#
Oops, also add
1
JPanel panel = WorldHandler.getInstance().getWorldCanvas();
Gamezocker Gamezocker

2014/2/18

#
Thats it, thanks it runs ! For all, who want to have it too:
1
2
3
4
5
6
7
import greenfoot.core.WorldHandler;
import javax.swing.*;
 
JPanel panel = WorldHandler.getInstance().getWorldCanvas(); 
JFrame f = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, panel);
ImageIcon img = new ImageIcon(this.getClass().getResource(" I M A G E "));
f.setIconImage(img.getImage());
ps. I have written it into the act method of my first world.
JetLennit JetLennit

2014/2/18

#
Sorry about messing it up so many times, but i am glad it worked in the end!
You need to login to post a reply.