This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

making image disappeared

 
rajendra peddinti
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

i am desiging a dx-ball game in awt/swing where, bricks will placed in rows, a ball will hit the bricks and what ever brick is touched by the ball should be disappeared.

so i've loaded images for bricks and animated ball. i used "clearRect"(java.awt.Graphics)for disappearing image depending on the ball position.

the problem is it is clearing the lower row perfectly and not going to the next row(obviously it wont go ) because it is clearing the same rectangle which it has already cleared.

so can any one suggest me how to remove an image completely(i think you got my sense in using "completley)?

thank you.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without knowing how you have drawn your bricks, it's difficult to say. If they are components (JPanel, JButton, JLabel, etc) then you can simply remove them from their parent.

However, from your description, I'm assuming you have overridden paintComponent and are drawing them manually that way? Could you give us a bit more info regarding this?
 
rajendra peddinti
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gregg,

your assumption is right. i've overridden paintComponent().following is my piece of code...
 
Campbell Ritchie
Sheriff
Posts: 48445
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You didn't include "super.paintComponent(g);"? Does that make any difference?
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic