Well, the OP could be erroneously drawing with the Graphics object returned by getGraphics, which works until repaint() is called. Many make that mistake...
It's really hard to try to figure out the cause of the problem, let alone a solution, without seeing the actual source code (hint!!).
Sorry - not been able to log on - thank you for your replys. Here's a couple of examples of code - the first one works, the second doesn't.
public class Cpan extends Applet{
public void init(){
setBackground(Color.white);
}
public void paint(Graphics g) {
g.setColor(Color.black);
//Draw Sqaures
g.drawRect(0, 0, 30, 30);
g.drawRect(30, 0, 30, 30);
g.drawRect(60, 0, 30, 30);
g.drawRect(90, 0, 30, 30);
g.drawRect(120, 0, 30, 30);
}
}
Above is extended to complete a 5*5 grid
Second:
public class Cpan2 extends Applet{
int x = 0;
int y = 0;
public void init(){
setBackground(Color.white);
}
public void paint(Graphics g) {
g.setColor(Color.black);
for (int a=0; a<5; a++){
for (int b=0; b<5; b++){
g.drawRect(x, y, 30, 30);
x = x +30;
}
x = 0;
y = y + 30;
}
Any ideas?
'y' in the second one is newer reset to 0. Try this:public void paint(Graphics g) {
g.setColor(Color.black);
int x=0; y=0;
for (int a=0; a<5; a++){
for (int b=0; b<5; b++){
g.drawRect(x, y, 30, 30);
x = x +30;
}
x = 0;
y = y + 30;
}
}