fullscreen tearing problem

I have a rendering loop in a fullscreen application and I’m getting slight tearing. It’s noticeable when I draw a 2d map on the screen and move around on it. The basic loop code is shown below. I would like to force the bufferStrategy to use page flipping, but I couldn’t figure out how to from the java tutorial on the subject. Any advice on how to fix the problem would be appreciated.

public static void main(String[] args) {
			GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
			GraphicsDevice device = env.getDefaultScreenDevice();
			new LostHavenClient(device);
	}

public LostHavenClient(GraphicsDevice device) {
        try {
            GraphicsConfiguration gc = device.getDefaultConfiguration();
            frmMain = new Frame(gc);
            frmMain.setUndecorated(true);
            frmMain.setIgnoreRepaint(true);
            device.setFullScreenWindow(frmMain);
            
            if (device.isDisplayChangeSupported()) {
                chooseBestDisplayMode(device);
            }

            frmMain.addMouseListener(this);
            frmMain.addKeyListener(this);
            frmMain.createBufferStrategy(2);
            BufferStrategy bufferStrategy = frmMain.getBufferStrategy();
            
            while (!done) {
                Graphics g = bufferStrategy.getDrawGraphics();
                render(g);
                g.dispose();
                bufferStrategy.show();
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        finally {
            device.setFullScreenWindow(null);
        }
    }

you may perform one or two more checks for the bufferStrategy if you want the best strat’ in use. There’s 2 easy callable methods: isPageFlipping and isMultiBuffering available for each GraphicsConfiguration. PageFlipping is supported on most platforms while the multibuffering that use 3+ buffers is for some accelerated systems.
???

I called getBufferCapabilities().isPageFlipping() on the gc variable in the above code and it returned true. Does this mean my system supports page flipping, or that my code actually uses page flipping? If it’s the former, how do I then make the graphicsConfiguration actually use page flipping?

Just to make sure I’m on the right track, what I’m getting is a black strip that sometimes flickers on the screen for a moment as I move around the map. It’s sometimes horizontal and sometimes vertical. It looks like a tearing problem rather than flicker from backbuffering since it only occurs in one part of the screen each time.

If this only happens when you’re scrolling around the screen, you might want to consider that it may be either an error with the scrolling code or an error with how you’re drawing the screen. For instance, you might be missing one tile at the edge of the screen because you’re not taking into account that you need to draw part of the next tile.

Actually, that just gave me an idea. I update the player’s position based on where he clicks, so if he clicks while the images being drawn, part of the images will be drawn based on his old coordinates and part based on his new ones. Once I fix that, I’ll post here and say if it worked.

EDIT: Yup, works great now. Thanks for the helping me think of that, fletchergames.