I've made a java game that I run in a separate window. No problem. I launch it in a separate window from an applet that simply is a start button. That works well.
But when the browser window with the start button is used to go to some other page, the game window disappears (is destroyed). How do I prevent that?
I'm sure the solution is very simple and has something to do with threads and the Runnable interface, but I haven't been able to figure it out...
A few details:
JDK 1.4
Thanks!
/Nojd
But when the browser window with the start button is used to go to some other page, the game window disappears (is destroyed). How do I prevent that?
I'm sure the solution is very simple and has something to do with threads and the Runnable interface, but I haven't been able to figure it out...
A few details:
JDK 1.4
Code:
// The applet which simply is a start button
public class HelloApplet extends JApplet implements ActionListener {
// ...
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(HELLO)) {
Hello h = new Hello();
}
}
}
// The game
public class Hello extends JFrame implements ActionListener, Runnable {
// ...
public void run() {
}
// This method is run when the Exit button is clicked
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand().equals(EXIT)) {
this.dispose();
}
}
}
Thanks!
/Nojd