Those Who Live On Mt. Olympus wrote:public void paint(Graphics g)
...
Subclasses can just override this method, as always. A subclass that just wants to specialize the UI (look and feel) delegate's paint method should just override paintComponent.
"Il y a peu de choses qui me soient impossibles..."
Stevens Miller wrote:siddarth, I believe that Campbell's advice will solve your problem. Swing double-buffers JPanels. I am guessing the problem is that you are painting your cloud after your call to super.paint(). If you do your drawing in paintComponent(), the JPanel's native paint() method will call it at the right time to be sure its effects reach the screen.
There are three kinds of actuaries: those who can count, and those who can't.
"Il y a peu de choses qui me soient impossibles..."
Piet Souris wrote:When it comes to overriding 'paint' or 'paintComponent', I think Stevens said it all.
There are three kinds of actuaries: those who can count, and those who can't.
Piet Souris wrote:I must confess: I didn't see that one coming!
Well, there are two ways to fix it:
1) do as I did: use the full path of your cloud image. That is a quick solution, but it will only work on your machine
2) make use of packages, in stead of using the default package. Do you use an IDE, like NetBeans or Eclipse? If so, create a package, and if your cloud image is in the same package as your .java files, then this will load your image:
Let us know if this works.
There are three kinds of actuaries: those who can count, and those who can't.