Canvas in fullscreen mode

The question has probably already been answered :
I’ve got a JFrame containing a Canvas, everything works fine in windowed mode but when i try to switch to fullscreen mode, my canvas doesn’t display anything anymore.
Is there anything more to add than the :

GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(this(=myJFrame));

is there any option i may have missed ?
If anyone can help me ;_;

On the newest developer update of Java on OS X. You get a gray screen when using a canvas inside a JFrame in fullscreen.

Lot’s of fiddling needed to get around it.

If you are on OS X, you can page me and I’ll try to make a working sample of how to get the fullscreen working in all cases.

try this:

public class FullCanvas extends Canvas {
int WIDTH=1024;
int HEIGHT=768;
int BUFFERS =2;
BufferStrategy mystrategy;

public FullCanvas() {
JFrame f = new JFrame(“Test”);
JPanel backPanel = (JPanel) f.getContentPane();
setBounds(0, 0, WIDTH, HEIGHT);
backPanel.setPreferredSize(new Dimension(WIDTH, HEIGHT));
backPanel.setLayout(null);
// add components
backPanel.add(this);
f.setBounds(0, 0, WIDTH, HEIGHT);

GraphicsEnvironment gren = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice grd = gren.getDefaultScreenDevice();

f.setUndecorated(true); 
f.setIgnoreRepaint(true); 
f.setResizable(false);

grd.setFullScreenWindow(f); 

DisplayMode dm = new DisplayMode(WIDTH, HEIGHT, 32, DisplayMode.REFRESH_RATE_UNKNOWN);
try {
  grd.setDisplayMode(dm);
}
catch (IllegalArgumentException e) {
  System.out.println("Error");
}

f.createBufferStrategy(BUFFERS);

try { // 
  Thread.sleep(1000); 
}
catch (InterruptedException ex) {}

mystrategy= getBufferStrategy(); 

this.createBufferStrategy(BUFFERS);
mystrategy= getBufferStrategy();
this.requestFocus();
this.setIgnoreRepaint(true);
f.setVisible(true);

}

loop …
rendering all compontents

}

it should works!

Yeah. Actually it worked all a long. It was a bug in the previous java runtime on OS X.

I’ve found that it’s simply easier to cut the Canvas use the Frame’s double buffering capabilities instead when going fullscreen. In one game, I use a Canvas for debugging/windowed mode and just the frame itself for fullscreen.