File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Game Development and the fly likes My paint method is moody today Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "My paint method is moody today" Watch "My paint method is moody today" New topic
Author

My paint method is moody today

Wes McClintock
Greenhorn

Joined: Jul 19, 2011
Posts: 25
I have literally no idea whats wrong here. The applet launches and runs fine, but doesn't display anything.

and here i declare my stuff in init()


and i have this stuff declared as well


Im new to java, so if having another "fix my code" thread bugs you Im sorry. your help is really appreciated.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18909
    
    8

If you override the paint() method with something simpler, like just colouring everything green, does that work?
Wes McClintock
Greenhorn

Joined: Jul 19, 2011
Posts: 25
Paul Clapham wrote:If you override the paint() method with something simpler, like just colouring everything green, does that work?

no, I tried removing anything involving images and just drew a a line, but it didn't work. I find this extremely weird because the code is taken almost line for line from my pong program, and than runs fine.
Spencer Zelle
Greenhorn

Joined: Jul 24, 2011
Posts: 2

Try making a call to the super classes's paint method. Something like this.


Also depending on what component your using to draw (if your using Swing or AWT) it is usually better to override paintComponent(). The reason for this is AWT uses paint() which handles other things like painting the components border, and the components "children", not just painting the component itself. Swing however, uses three paint methods paintComponent(), paintBorder(), and paintChildren() to do all the painting. So if your using a Swing component overriding paintComponent() means your not messing with the component's border and child painting.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: My paint method is moody today