Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Graphics on Applets

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
super.paint(g); doesnt help
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
  • 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...
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic