Painting on Top of Image
I'm trying to design an applet which simulates a radar screen. Although I'm a novice, I have managed to create the radar itself OK.
However, I would like the radar screen to "sit" on a "console", and I'm trying to use an image file as this background console. Although the image loads and displays AOK, I can't seem to draw the radar on top of it.
I have tried using both the Image and Graphics objects, for example:
public class radar extends Applet implements Runnable {
private Image img;
private Graphics buffer;
.....
// First get the 'console' image... this works AOK....
buffer=getImage(getDocumentBase(),"ar200.png");
// Now I need to paint the radar screen on top of the
// image, but it applet won't work when I add...
buffer=img.getGraphics();
// I've used getGraphics separately - without preloading
// an image - to create the animated radar screen, which
// works AOK, for example:
public void paint(Graphics g) {
// Set the radar screen grid circles
buffer.setColor(Color.gray);
buffer.drawOval(0, 0, aW, aH);
buffer.drawOval(aW/2/4*1, aH/2/4*1, aW/4*3, aH/4*3);
buffer.drawOval(aW/2/4*2, aH/2/4*2, aW/4*2, aH/4*2);
buffer.drawOval(aW/2/4*3, aH/2/4*3, aW/4*1, aH/4*1);
.... etc
g.drawImage (img,0,0,this);
.... etc
So, I can display an imported "console" image file, OR draw and display an animated radar screen - but not both! I think it might be an issue with combining "on-screen" and "off-screen" painting, but I'm not at all sure.
If anyone could suggest the method to accomplish this, or point me to an online resource that I can study, I'd really appreciate it.
MTIA, Max

