Fomre triangle java

Résolu/Fermé
milou - 26 mai 2009 à 19:01
 milou - 26 mai 2009 à 20:43
Bonjour,

je suis en train de faire un projet en java et j'en suis a la partie interface ( fenetre, panneau & co ...)
et ça va pas du tout !!

de la même façon qu'on peut faire un cercle et un carée(rectangle) je voudrais savoir comment faire la forme triangle !

merci de vos réponses
A voir également:

2 réponses

Utilisateur anonyme
26 mai 2009 à 20:07
Salut,

Ici: https://docs.oracle.com/javase/6/docs/api/
et en sélectionnant la classe Graphics (fenêtre All Classes à gauche) tu trouveras la méthode:

drawPolygon
public abstract void drawPolygon(int[] xPoints,
int[] yPoints,
int nPoints)Draws a closed polygon defined by arrays of x and y coordinates. Each pair of (x, y) coordinates defines a point.
This method draws the polygon defined by nPoint line segments, where the first nPoint - 1 line segments are line segments from (xPoints[i - 1], yPoints[i - 1]) to (xPoints[i], yPoints[i]), for 1 ≤ i ≤ nPoints. The figure is automatically closed by drawing a line connecting the final point to the first point, if those points are different.


Parameters:
xPoints - a an array of x coordinates.
yPoints - a an array of y coordinates.
nPoints - a the total number of points.

Cordialement,

Dan
0
ben merci bcp jvé voir sa !
0