• 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

Graphics on Applets

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I made an Applet, and tried to put graphics on it but when I do the code runs but I have to minimize the applet then make it big again to see the image. This is a Java Project im doing but I am really stuck can someone help me?



Heres the starter

 
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try inserting

super.paint(g);

as the first method call in your paint() method.
[ May 21, 2006: Message edited by: Garrett Rowe ]
 
James Han
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
super.paint(g); doesnt help
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The

tempG = g;

in your paint method doesn't make any sense. The graphics object is created by AWT when it calls the paint method, and isn't valid anymore outside of the paint method. Later calling paint with tempG in ChangeScreen therefore doesn't do anything useful.

You should never call paint directly. Instead, if you want the component to update its appearance, you should call repaint() instead. That will cause AWT to call your paint method with a valid graphics object.

Moving to the AWT forum, where the experts will correct me...
 
I'd appreciate it if you pronounced my name correctly. Pinhead, with a silent "H". Petite ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic