For applets you don't create a panel, the applet is a panel. Also, the applet size is determined by the html that calls it. So the applet itself is pretty simple something like:
import java.awt.*;
import javax.swing.*;
import java.util.Random;
public class JavaGraphApp extends JApplet {
private final int Width=640;
private final int Height=480;
private int x=0,y=0;
Random rnd;
public void init() {
rnd=new Random();
}
public void paint (Graphics g) {
for (int i=0;i<100;i++) {
x=(int) (rnd.nextFloat()*Width);
y=(int) (rnd.nextFloat()*Height);
g.drawLine(x,y,x,y);
}
}
}
will do what you're looking for. Instead of defining the width and height probably
you should use the getSize().width and getSize().height methods in case you specifiy different dimensions in the html.