This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Game Development and the fly likes using graphics object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "using graphics object" Watch "using graphics object" New topic

using graphics object

venkatesh pendharkar
Ranch Hand

Joined: Apr 29, 2006
Posts: 106
Hi i am trying to create a game in which i need to use drawImage of graphics method outside the paint method.I am trying it in the following way.The code is complilling fine & also not giving any exception but it doesn draw any image.Can anyone help me out??? I am sending some part of this code.

import java.awt.*;
import java.applet.*;
public class MyImage extends Applet
Dimension d;
Graphics g1;// this is a variable of graphics object
int x=10;
int y=10;
Image ir,ib,ig,iy,i1;

public void init()
d = getSize();

public void paint(Graphics g)
if (g1==null && d.width>0 && d.height>0)
i1 = createImage(d.width, d.height); // creating the graphics objetct
g1 = i1.getGraphics();
if (g1==null || i1==null)

public void met()
g1.drawImage(ir,50,50,this); //drawing an image with g1(graphics object)

public void getImages()

Ryan Giomi

Joined: Jan 24, 2007
Posts: 9
Is it absolutely required that your code be exactly similar to the way you have it written?
Also, is this for an applet or not?
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: using graphics object
jQuery in Action, 3rd edition