Draw Triangle - Java java.awt

Java examples for java.awt:Graphics2D

Description

Draw Triangle

Demo Code


//package com.java2s;
import java.awt.*;

public class Main {
    public static void DrawTriangle(Graphics g, int x, int y, int w, int h) {
        //Draw the three lines to make us a nice triangle
        g.drawLine(x, y, (x - w / 2), (y + h));
        g.drawLine(x, y, (x + w / 2), (y + h));
        g.drawLine((x - w / 2), y + h, (x + w / 2), y + h);
    }/*from  w w w  .  j a  va2 s  . co m*/
}

Related Tutorials