PDA

Click to See Complete Forum and Search --> : Easy Q


Evan
May 16th, 2001, 02:34 PM
I asked a question of why this other code didnt work.
I was givin this code here


public void paint(Graphics g)
{
g.drawString("string",xloc,yloc);
}


This writes directly on the applet?

So I tried to use it like this


/**Start the applet*/
public void start() {
paint(appletl);
}

public void paint(Graphics g)
{
g.drawString("Hi there",11,11);
}


It wont work. How do I call paint, and what is 'Graphics g'?

Wynd
May 16th, 2001, 04:22 PM
You don't have to call it. Look at this applet:


package test;
import java.awt.*;
public class test extends JApplet
{
int x = 5;
int y = 25;
public void paint(Graphics g)
{
g.drawString("Hello World", x, y);
}
}


This will automatically paint "Hello World" to the applet.