This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

My paint method is moody today

 
Wes McClintock
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20191
26
MySQL Database
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you override the paint() method with something simpler, like just colouring everything green, does that work?
 
Wes McClintock
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
Eclipse IDE Linux Ubuntu
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic