permaculture playing cards*
The moose likes Swing / AWT / SWT and the fly likes Graphics on Applets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Graphics on Applets" Watch "Graphics on Applets" New topic
Author

Graphics on Applets

James Han
Greenhorn

Joined: May 21, 2006
Posts: 2
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

Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296
Try inserting

super.paint(g);

as the first method call in your paint() method.
[ May 21, 2006: Message edited by: Garrett Rowe ]

Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
James Han
Greenhorn

Joined: May 21, 2006
Posts: 2
super.paint(g); doesnt help
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
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...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Graphics on Applets
 
Similar Threads
Double Buffering help!
Beginner game
Rotating an image
Gray box where my applet should be
Refactoring