• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DoubleBuffering when there are buttons

 
Christopher Young
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Norm Radder
Ranch Hand
Posts: 733
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic