opengl won't let me change resolution

when the my game initializes i set fullscreen mode and the resolution i want. this works fine when i don’t enable opengl. but when i do, it won’t permit any change of resolution (even if i try to set the resolution to the current resolution, it tells me that that display mode isn’t available). i change resolution like so:
public void SetResolution(int PWidth,int PHeight,int PDepth)
{
if (!gd.isDisplayChangeSupported())
{
System.out.println(“Display mode changing not supported”);
return;
}
boolean available=false;
DisplayMode[] modes = gd.getDisplayModes(); // modes list
for(int i = 0; i < modes.length; i++) {
if ( width == modes[i].getWidth() &&
height == modes[i].getHeight() &&
bitDepth == modes[i].getBitDepth() )
{
available=true;
}
}
if (!available) {
System.out.println(“Display mode (” + PWidth + “,” +
PHeight + “,” + PDepth + “) not available”);
return;
}
DisplayMode dm = new DisplayMode(PWidth, PHeight, PDepth,
DisplayMode.REFRESH_RATE_UNKNOWN); // any refresh rate
try {
gd.setDisplayMode(dm);
System.out.println(“Display mode set to: (” +
PWidth + “,” +
PHeight + “,” + PDepth + “)”);
}
catch (IllegalArgumentException e)
{ System.out.println(“Error setting Display mode (” +
PWidth + “,” +
PHeight + “,” + PDepth + “)”+e.toString()); }

}

are you running linux? - if so, you cannot change resolution on any distributable VM’s yet. You will have to use LWJGL to do that then.

Nope, i’m running on win xp

Why do you create a new DisplayMode object?

It’s always best to pick a DisplayMode that you got from “getDisplayModes()”

absolutely right…
that changed the problem, but didn’t solve it-
now the resolution did change, but the screen remained black. so i added a short (two seconds!) waiting time in order to allow the new calibration to “settle in”. so now in the first frame everything looks ok, but than every where on the screen where an image should be drawn, appears a white rectangle instead (?!). plus, the speed drops signficantly, as though opengl wasn’t even enabled… very wierd…

something i thought of- the images get replaced with a white rectangle only after they have been drawn a couple of times, so i guess it happenes the moment they are cached! what’s happening and why?