• 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

My paint method is moody today

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 2
Eclipse IDE Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
LOOK! OVER THERE! (yoink) your tiny ad is now my tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic