|
-
March 6th, 2000, 10:08 AM
#1
getGraphics() returning null
I am trying to load an image into an application and display it in my program. When I try to get the graphics in the example below, the graphics object is null. How can I get the graphics?
Toolkit tk = getToolkit();
bg = Color.blue;
setBackground( bg );
image1 = tk.getImage( "images/New.gif" );
g.drawImage( image1, 3, 3, parent );
-------------------------------------------
T. Sean Ryan
http://rastos0.kjm.htmlplanet.com
-
March 6th, 2000, 06:51 PM
#2
Re: getGraphics() returning null
You need use Component.getGraphics() to get the Graphics context for
the component before you paint something on the component.
good luck
Alfred Wu
-
March 6th, 2000, 07:38 PM
#3
Re: getGraphics() returning null
you cant get the graphics inside a component's constructor. Check whether you have
put this code inside the Component's constructor.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|