*/
public class BufferStrategyExceptionTest {
private static final int TEST_REPS = 20;
public static void main(String[] args) {
GraphicsDevice gd =
GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice();
for (int i = 0; i < TEST_REPS; i++) {
TestFrame f = new TestFrame();
f.pack();
f.setSize(400, 400);
f.setVisible(true);
if (i % 2 == 0) {
gd.setFullScreenWindow(f);
}
// generate a resize event which will invalidate the peer's
// surface data and hopefully cause an exception during
// BufferStrategy creation in TestFrame.render()
Dimension d = f.getSize();
d.width -= 5; d.height -= 5;
f.setSize(d);
f.render();
gd.setFullScreenWindow(null);
sleep(100);
f.dispose();
}
System.out.println("Test passed.");
}