code request: fullscreen/windowed switching

Anyone have a snippet of code that can move back and forth between windowed/fullscreen?

i.e.

public void setFullScreen(DisplayMode mode, int buffers) {
// etc
}

public void setWindowed(int width, int height) {
// etc
}

… elsewhere…
DisplayMode dm = new DisplayMode(640, 480, 32, 0);

setFullScreen(dm, 3);
…and later on…
setWindowed(640, 480);
…and later on…
setFullScreen(dm, 2);
…and later on…
setWindowed(800, 600);

etc…

The code I wrote that worked, is now broken (detailed in another post), so now I’m asking if someone has working code I could look at.

Edit: I probably wont be putting the code back up till the fullscreen deadlock bug is fixed.

I also asked in this post why isDisplayChangeSupported() was returning false on win2k: you have to set a setFullscreenWindow(frame) before calling it.

meh.

[quote] To make a long story short, isDisplayChangeSupported() is returning false and that revealed a bug in another method. So thats why it worked a long time ago, and then wasn’t working now. Anyone know why thats returning false on win2k? :confused:
[/quote]
I can´t say why it does but I can verify that it also returns false on my win2k system. Had the similar problem that my code stopped to work, and it was becuase I had been writing the fullscreen mode change code on NT4 and when I tried it at home nothing worked. So I have disabled the check of isDisplayChangeSupported() in my code.