Hi, we got a problem,
//Main-Class;
public void actionPerformed(ActionEvent e){
if (e.getSource() == mainMenuButtons[0]) {
try {
GameWindow.gw.setLoadingPanel();
} catch (IOException e2) {
e2.printStackTrace();
}
PictureIds.setObjectPictureIds();
PictureIds.setTerrainPictureIds();
try {
GameWindow.gw.setGamePanel();
} catch (IOException e1) {
e1.printStackTrace();
}
//Game-Window-class
public void setLoadingPanel() throws IOException{
GameWindow.this.getContentPane().removeAll();
lpanel = new LoadingPanel();
this.add(lpanel);
this.validate();
this.repaint();
lpanel.grabFocus();
lpanel.repaint();
}
//LoadingPanel-class
public LoadingPanel() {
super();
this.setFocusable(true);
this.grabFocus();
System.out.println("Loading Const.");
}
public void paint(Graphics g) {
super.paint(g);
System.out.println("Loading");
g.drawImage(loadingScreen, 0, 0, null);
g.dispose();
}
}
//GamePanel-class
public GamePanel() throws IOException {
super();
moveThread = new MoveThread(this);
Thread start = new Thread(moveThread);
start.start();
........
}
Our problem is that the paint-method in LoadingPanel-class is never called. If you comment GameWindow.gw.setGamePanel() out, “PictureIds.setObjectPictureIds() PictureIds.setTerrainPictureIds();” are both called before the paint-method in the LoadingPanel-class.
It should repaint after the constructor of LoadingPanel, and before the other methods are called because a loading-screen which is called after the loading is quite useless.
best regards