I did this and it worked ok:
GraphicsConfiguration gc = device.getDefaultConfiguration();
mainFrame = new Frame(gc) {
public void paint(Graphics g){}
public void update(Graphics g){} };
mainFrame.setIgnoreRepaint(true);
if ( doFullScreen && device.isFullScreenSupported())
{
mainFrame.setUndecorated(true);
device.setFullScreenWindow(mainFrame);
if (device.isDisplayChangeSupported())
{
chooseBestDisplayMode(device);
//in my case all modes are 640x480
mainFrame.setBounds(0,0,640,480);
}
}
public static void chooseBestDisplayMode(GraphicsDevice device)
{
DisplayMode best = getBestDisplayMode(device); // from a list of modes the game supports
if (best != null)
{
device.setDisplayMode(best);
}
}