No frame refreshing when buffered window is called/created
Hi,
i'm programming a java-based game. It uses a JFrame that calls an "accelerated window" ( a buffered window with a Graphics2D Object ) to draw a basketball simulation. The problem is that when the accelerated window is running ( loop ) the refreshing and the listeners of the main window doesn't work properly (note that accelerated window is called by a Game class that extends Thread... ). Why? Thanks
// Class Game is called by a main JFrame...
publicclass Gameextends Thread{
.
.
.
public Game( ... ){
...
court =new Court2D();
court.setVisible(true);
court.draw();
...
}
...
}
/* ************************************************* */
publicclass Court2Dextends Canvas{
...
public Court2D(){
container =new JFrame("Court");
container.addWindowListener(new WindowAdapter(){
publicvoid windowClosing( WindowEvent e ){
container.dispose();
}
});
JPanel panel = (JPanel) container.getContentPane();
panel.setPreferredSize(new Dimension( WIDTH, HEIGHT));
panel.setLayout(null);
setBounds(0,0, WIDTH, HEIGHT);
panel.add(this);
setIgnoreRepaint(true);
...
container.setResizable(false);
container.setVisible(true);
requestFocus();
createBufferStrategy(2);
strategy = getBufferStrategy();
draw();
}
publicvoid draw(){
Graphics2D g = (Graphics2D) strategy.getDrawGraphics();
...//draw something...
g.dispose();
strategy.show();
}
...
}
picture: http://backspace.altervista.org/JBM/problem.jpg

