• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

making image disappeared

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gregg,

your assumption is right. i've overridden paintComponent().following is my piece of code...
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You didn't include "super.paintComponent(g);"? Does that make any difference?
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic