File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes DoubleBuffering when there are buttons Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "DoubleBuffering when there are buttons" Watch "DoubleBuffering when there are buttons" New topic
Author

DoubleBuffering when there are buttons

Christopher Young
Ranch Hand

Joined: Nov 02, 2007
Posts: 63
Hi. I have a problem. I am making Connect Four and just implemented DoubleBuffering to make it smooth when i repaint (as I may add animation later), and I have buttons that the user clicks on to drop tokens into the board.

However, when I implemented DoubleBuffering, it paints over the buttons I have. They are there, but invisible or flicker when moused over.

I suspect the problem is due to the fact that it is capturing the entire screen. Any way to work around that? This is how I have implemented it.



I can call g.drawImage(IBuffer, 0, 50, this) with a bigger number and get the buttons to show up just fine but the board is far too far away from the buttons. I want them closer.

What is a good way to implement double buffering when buttons are on the same screen?


Technology can never substitute for knowledge.
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 686
Who calls your draw method?
Can you put the buttons in a separate container from the component that draw draws on?
Christopher Young
Ranch Hand

Joined: Nov 02, 2007
Posts: 63
NM. I figured out the issue.

Before I implemented DoubleBuffering, I had offset what I drew by an amount so they'd show up under the buttons. When I implrmented DoubleBuffering, I forgot to take this offset away and so was offsetting an offset even more to avoid covering up the buttons.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DoubleBuffering when there are buttons