Java Applet ile üçgen çizdirme metotunu kullanmak için;

Kod:
importjava.awt.*;
importjava.applet.Applet;

publicclass x extendsApplet{

publicvoid paint(Graphics g){
        drawTriangle(g, 20, 180, 100, 110);
        drawTriangle(g, 125, 180, 60, 70);
}

privatevoid drawTriangle(Graphics g, int tabanX, int tabanY,
int taban, int yukseklik){
int sagX = tabanX + taban;
int ustX = tabanX + taban / 2;
int ustY = tabanY - yukseklik;

        g.drawLine(tabanX, tabanY, sagX, tabanY);
        g.drawLine(sagX, tabanY, ustX, ustY);
        g.drawLine(ustX, ustY, tabanX, tabanY);

}
}