The actual JFrame closes fine, but for the split second it appears, its blank. Could it be a problem with the resources in the Jar file?
public class FrontEnd extends Canvas implements Stage, KeyListener {
…
public static void main(String[] args) {
FrontEnd front = new FrontEnd();
front.game();
}
public FrontEnd() {
// Initialise New Window
spriteCache = new SpriteCache();
soundCache = new SoundCache();
JFrame ventana = new JFrame("RA Invaders");
JPanel panel = (JPanel) ventana.getContentPane();
setBounds(0, 0, Stage.WIDTH, Stage.HEIGHT);
panel.setPreferredSize(new Dimension(Stage.WIDTH, Stage.HEIGHT));
panel.setLayout(null);
panel.add(this);
ventana.setBounds(0, 0, Stage.WIDTH, Stage.HEIGHT);
ventana.setVisible(true);
ventana.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ventana.setResizable(false);
createBufferStrategy(2);
strategy = getBufferStrategy();
requestFocus();
addKeyListener(this);
setIgnoreRepaint(true);
BufferedImage cursor = spriteCache.createCompatible(10, 10,
Transparency.BITMASK);
Toolkit t = Toolkit.getDefaultToolkit();
Cursor c = t.createCustomCursor(cursor, new Point(5, 5), "null");
setCursor(c);
}
…
public void game() {
// INITIALISE GAME //
initGame();
initLevel();
while (isVisible()) {
t++;
long startTime = System.currentTimeMillis();
checkForEndOfLevel();
updateWorld();
checkCollisions();
paintWorld();
usedTime = System.currentTimeMillis() - startTime;
do {
Thread.yield();
} while (System.currentTimeMillis() - startTime < 17);
}
}
…
That’s basically the main part of the code that deals with the JFrame, if you need anything else, I’ll post/email it.
Any ideas?