• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

DoubleBuffering when there are buttons

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Rancher
Posts: 5018
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Be reasonable. You can't destroy everything. Where would you sit? How would you read a tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic