I am designing a psychology experiment with java applets. I have to make my java applets full screen. What is the best way of doing this and how can I do this.
Since I
I've found a solution for this problem that works fine. Tested in Linux 64 bits (Chrome and Firefox) and in Windows 7 64 bits (Chrome and Explorer)
The only problem has been that my applet uses all the space in the browser and when the user switch off the full screen mode, the applet is not scaled to the browser size. The solution has been to keep the previous size of the applet before to enter in a fullscreen mode and then, set this size when the applet returns to the normal mode:
public void setFullScreen() {
if (!this.fullscreen) {
size = this.getSize();
if (this.parent == null) {
this.parent = getParent();
}
this.frame = new Frame();
this.frame.setUndecorated(true);
this.frame.add(this);
this.frame.setVisible(true);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] devices = ge.getScreenDevices();
devices[0].setFullScreenWindow(this.frame);
this.fullscreen = true;
} else {
if (this.parent != null) {
this.parent.add(this);
}
if (this.frame != null) {
this.frame.dispose();
}
this.fullscreen = false;
this.setSize(size);
this.revalidate();
}
this.requestFocus();
}