Uhm... weno, se me había pasado que era un Applet, incluso cuando estabamos hablando que era uno. :P
Un Applet tiene una entrada distinta que main: el métido
init.
Mira este ejemplo:
Código PHP:
public class Prueba extends Applet {
@Override
public void init() {
System.out.println("Inicio...");
}
public void paint(int x1,int y1,int x2,int y2) {
this.getGraphics().setColor(Color.BLACK);
this.getGraphics().drawLine(x1,y1,x2, y2 );
}
@Override
public void paint(Graphics g) {
this.paint(0, 0, this.getWidth(), this.getHeight());
this.paint(0, this.getHeight(), this.getWidth(), 0);
}
}
Se sobrecarga el método
paint para llamar al método de dibujo de las rectas. Puedes enviar el objeto Graphics a tu método desde
paint o puedes seguir haciéndolo con
this.getGraphics().