wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes problem with paint methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "problem with paint methods " Watch "problem with paint methods " New topic
Author

problem with paint methods

anomyth kumar
Greenhorn

Joined: Feb 27, 2010
Posts: 1
this is the code which draws the star image to the frame



while using the normal paint method it refreshes the frame and draws the star image but while using the paintcomponent method the image is getting dragged and while using paintchildren the image is drawn as that of normal paint method

would anybody explain what is exactly happening and the difference between these three paint methods.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
Start here: http://java.sun.com/docs/books/tutorial/uiswing/painting/index.html


Ping & DNS - updated with new look and Ping home screen widget
Chris Nash
Greenhorn

Joined: May 20, 2009
Posts: 28
I don't see where y is getting set to anything but 0, but I didn't do an exhaustive examination of the code. I think your problem is here:



Try this instead:


Calling the super method makes it behave like a regular JComponent, but still implements your painting. You may have to set the component to transparent (setOpaque(false)), but other than that, it should behave like you expect it to. HTH


- Frecklefoot
"What you are good at is not as important as being good at something." --Robert B.Parker
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with paint methods
 
Similar Threads
How to transfere ActionListener to anothe Class
Please check if the paint method used properly
can not move the paddle in this program
Small event handling problem, need to implement a stop
Game(ball breaker) developed using swings not running.