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

[1282 byte] By [Serfioa] at [2007-11-26 12:54:24]
# 1
I think you want to make paintScreen() call paint on the frame and have the bit which draws from the backbuffer in your panel's paintComponent method.
YAT_Archivista at 2007-7-7 16:46:19 > top of Java-index,Other Topics,Java Game Development...