Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie - Repainting images

Status
Not open for further replies.

NiceButDim

Programmer
Feb 12, 2002
154
GB
Hi, I am very new to Java. I have a problem with displaying an image;

-------------------------------
package bts;

import java.applet.*;
import java.awt.*;

public class Match extends Applet {
Image box;

public void init() {
prepare();
}

public void prepare() {
box = createImage(700,100);
Graphics g = box.getGraphics();
g.setColor(Color.RED);
g.fillRect(0,0, 700,100);
}


public void paint(Graphics g) {
g.drawImage(box,10,10,this);
}
}
-------------------------------

This code simply draws a red rectangle on the top left of my browser. That works fine. However, if I then drag another window over my rectangle, it is not always redrawn.
Can anyone explain what I am doing wrong.

Thanks.

john.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top