All pastes #903333 Raw Edit

Something

public text v1 · immutable
·published 2008-02-14 05:12 UTC
rendered paste body
import javax.swing.*;
import java.awt.*;
import java.awt.image.*;
public class DemoPageFlipping extends JFrame
{
	public DemoPageFlipping(GraphicsConfiguration c)
	{
		super(c);
	}
	public void begin()
	{
		setUndecorated(true);
		setIgnoreRepaint(true);
		getGraphicsConfiguration().getDevice().setFullScreenWindow(this);
		
		createBufferStrategy(2);
		
		BufferStrategy bs = getBufferStrategy();
		
		for(int i = 0; i<100;i++)
		{
			Graphics g = bs.getDrawGraphics();
			g.setColor(Color.BLACK);
			g.fillRect(0,0,getWidth(),getHeight());
			g.setColor(Color.CYAN);
			if (i%2==0)
				g.fillOval(50,50,100,100);
			else
				g.fillOval(200,200,100,100);
			bs.show();							//flips the page
			g.dispose();
		}	
	}
		
	public static void main(String[] args)
	{
		GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
		
		GraphicsDevice d = e.getScreenDevices()[0];
		
		DemoPageFlipping demo = new DemoPageFlipping(d.getDefaultConfiguration());
		
		demo.begin();
	}
}