Double Buffering

Graphics2D bufferGraphics;Image offscreen;offscreen=getImage(getDocumentBase(),"india.gif");bufferGraphics = (Graphics2D)offscreen.getGraphics();i m able to draw only shapes but not image in this so how can i ?
[252 byte] By [Anand_Agrawala] at [2007-11-26 22:04:21]
# 1

Do you have a specific question or do we need to guess?

If you want further help post a Short, Self Contained, Compilable and Executable, Example Program ([url http://homepage1.nifty.com/algafield/sscce.html]SSCCE[/url]) that demonstrates the problem.

And don't forget to use code formatting when posting code

http://forum.java.sun.com/help.jspa?sec=formatting

Rodney_McKaya at 2007-7-10 10:47:29 > top of Java-index,Desktop,Core GUI APIs...
# 2
that's okbut still i m not founding any solution
Anand_Agrawala at 2007-7-10 10:47:29 > top of Java-index,Desktop,Core GUI APIs...
# 3

Graphics2D bufferGraphics;

Image offscreen;

offscreen=getImage(getDocumentBase(),"india.gif");

bufferGraphics = (Graphics2D)offscreen.getGraphics();

bufferGraphics.drawString(..)

bufferGraphics.drawLine(..)

--

But how to ?

--

bufferGraphics.drawImage(?)?

Thanks in advance

Anand_Agrawala at 2007-7-10 10:47:29 > top of Java-index,Desktop,Core GUI APIs...
# 4
What do you mean "how to?"You use drawImage() - it looks like you've figured that out.What's the problem you're having?
itchyscratchya at 2007-7-10 10:47:29 > top of Java-index,Desktop,Core GUI APIs...
# 5
bufferGraphics.drawImage(img,0,0,this);but image is not display in applet
Anand_Agrawala at 2007-7-10 10:47:29 > top of Java-index,Desktop,Core GUI APIs...
# 6
public void paint(Graphics g){g2d=(Graphics2D)g;g2d.drawImage(offscreen,0,0,this);g2d.setBackground(Color.gray);}
Anand_Agrawala at 2007-7-10 10:47:29 > top of Java-index,Desktop,Core GUI APIs...
# 7
I have the same problem, please help!
Sticksnapa at 2007-7-10 10:47:29 > top of Java-index,Desktop,Core GUI APIs...
# 8
try bufferGraphics.drawImage(img, 0, 0, null);
sekizoglua at 2007-7-10 10:47:29 > top of Java-index,Desktop,Core GUI APIs...
# 9

You need to create a Graphics object

import java.awt.*;

import java.applet.*;

public class This extends Applet

{

Image offscreen;

Graphics2D bg2;

public void init()

{

setSize(800, 600);

offscreen = createImage(getWidth(), getHeight());

bg2 = (Graphics2D)offscreen.getGraphics();

}

public void paint(Graphics g)

{

bg2.fillOval(50,50,500,500);

g.drawImage(offscreen,0,0,this);

}

}

Message was edited by:

keseldude

keseldudea at 2007-7-10 10:47:29 > top of Java-index,Desktop,Core GUI APIs...
# 10

> Graphics2D bufferGraphics;

> Image offscreen;

>

>

> offscreen=getImage(getDocumentBase(),"india.gif");

> bufferGraphics =

> (Graphics2D)offscreen.getGraphics();

>

> i m able to draw only shapes but not image in this

>

> so how can i ?

try it thusly

Image indiaImage = getAppletContext().getImage(new URL(getCodeBase(),"india.gif") );

Then try drawing it.

(T)

tswaina at 2007-7-10 10:47:29 > top of Java-index,Desktop,Core GUI APIs...