File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes making image disappeared Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "making image disappeared" Watch "making image disappeared" New topic

making image disappeared

rajendra peddinti

Joined: Jun 05, 2007
Posts: 19

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

Joined: Jul 11, 2001
Posts: 15302

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?

GenRocket - Experts at Building Test Data
rajendra peddinti

Joined: Jun 05, 2007
Posts: 19

your assumption is right. i've overridden paintComponent().following is my piece of code...
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46412
You didn't include "super.paintComponent(g);"? Does that make any difference?
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
I agree. Here's the link:
subject: making image disappeared
It's not a secret anymore!