That statement will set the Frame's size to 1024 x
768. If you want to change the screen-resolution of
your monitor, the only option I see is to use JNI.
?????????????
No need for jni here!
And yes you can change to any ( supported ) resolution.
This is a simple demo:
It read the current resolution and opens a new frame (fullscreen) in 1024 x 768.
And later change the resolution back to old one.
import java.awt.Window;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.DisplayMode;
import java.awt.Frame;
public class DisplayModeTest0
{
public DisplayModeTest0()
{
GraphicsDevice myDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
Frame frame = new Frame();
Window w = new Window( frame );
w.setSize(500,500);
w.setVisible(true);
DisplayMode oldDisplayMode = myDevice.getDisplayMode();
DisplayMode newDisplayMode = new DisplayMode( 1024,768, 32, 85 );
try
{
myDevice.setFullScreenWindow(w);
myDevice.setDisplayMode(newDisplayMode);
Thread.sleep(5000);
}
catch( Exception e )
{
e.printStackTrace();
}
finally
{
myDevice.setDisplayMode(oldDisplayMode);
myDevice.setFullScreenWindow(null);
}
System.exit(0);
}
public static void main(String[] args)
{
DisplayModeTest0 displayModeTest = new DisplayModeTest0();
}
}
Need more information start read the fullscreen guid:
http://java.sun.com/docs/books/tutorial/extra/fullscreen/index.html
good luck!