active rendering and JMenu popup...HowTO?
Hi,
I have made a little game which use "Active rendering".
I have a JFrame with a JMenuBar
Inside the JFrame I have myJPanel (getContentPane().add(myJPanel, BorderLayout.CENTER); ) which contains the running cicle below:
while(running) {
gameUpdate();
gameRender();
paintScreen();
afterTime = System.nanoTime();
timeDiff = afterTime - beforeTime;
sleepTime = (periodo - timeDiff) - overSleepTime;
if (sleepTime > 0) {
try {
Thread.sleep(sleepTime/1000000L); // nano -> ms
} catch(InterruptedException ex){}
}
beforeTime = System.nanoTime();
}
private void gameRender() {
if (!win && !gameOver) {
//draw on my offScreen image
}
}
private void paintScreen() {
screen = (Graphics2D) getGraphics();
screen.drawImage(offScreen, xDraw, yDraw, null);
}
My problem is that my JMenu, when opened, are overlapped from the running cicle
See image below:
[url=http://img222.imageshack.us/my.php?image=jmenuerrorxi5.jpg][img=http://img222.imageshack.us/img222/4981/jmenuerrorxi5.th.jpg][/url]
How I can avoid this Problem?
Thanks,
Serfio
Message was edited by:
Serfio

