I find arcgis hard to code.
Here is some VBA code I wrote that works. It makes a triangle, but adding a few more sides is straight forward.
Private Sub Polyline_Click()
'get the GraphicsContainer and the map spatial reference
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument
Dim pGraphicsContainer As IGraphicsContainer
Set pGraphicsContainer = pMxDoc.ActiveView
Dim pColor As IColor
Set pColor = New RgbColor
pColor.RGB = RGB(0, 0, 0)
Dim pSLS As ISimpleLineSymbol
Set pSLS = New SimpleLineSymbol
pSLS.Color = pColor
pSLS.Style = esriSLSSolid
pSLS.Width = 4
Dim pStartPoint As IPoint
Set pStartPoint = New Point
pStartPoint.PutCoords 117, 0
FromPoint = pStartPoint
Dim pEndPoint As IPoint
Set pEndPoint = New Point
pEndPoint.PutCoords 0, -60
ToPoint = pEndPoint
'Create LINE Element
Dim pElement As IElement
Set pElement = New LineElement
Dim pLineElement As ILineElement
Set pLineElement = New LineElement
pLineElement.Symbol = pSLS
Set pElement = pLineElement
Dim pGeometryCollection As IGeometryCollection
Set pGeometryCollection = New Polyline
' Dim pSeg As ISegment
Dim pSegcoll As ISegmentCollection
Set pSegcoll = New Path
Dim pLine As ILine
Set pLine = New Line
pLine.PutCoords pStartPoint, pEndPoint
pSegcoll.AddSegment pLine
' pSegcoll.AddSegment pLine.ToPoint
pGeometryCollection.AddGeometry pSegcoll
'pLine.FromPoint = pStartPoint
'pLine.ToPoint = pEndPoint
Dim pStartPoint2 As IPoint
Set pStartPoint2 = New Point
pStartPoint2.PutCoords 0, -60
FromPoint = pStartPoint2
Dim pEndPoint2 As IPoint
Set pEndPoint2 = New Point
pEndPoint2.PutCoords 10, 60
ToPoint = pEndPoint2
Dim pLine2 As ILine
Set pLine2 = New Line
pLine2.PutCoords pStartPoint2, pEndPoint2
pSegcoll.AddSegment pLine2
pGeometryCollection.AddGeometry pSegcoll
Dim pStartPoint3 As IPoint
Set pStartPoint3 = New Point
pStartPoint3.PutCoords 10, 60
FromPoint = pStartPoint3
Dim pEndPoint3 As IPoint
Set pEndPoint3 = New Point
pEndPoint3.PutCoords 117, 0
ToPoint = pEndPoint3
Dim pLine3 As ILine
Set pLine3 = New Line
pLine3.PutCoords pStartPoint3, pEndPoint3
pSegcoll.AddSegment pLine3
pGeometryCollection.AddGeometry pSegcoll
pElement.Geometry = pGeometryCollection
pGraphicsContainer.AddElement pElement, 0
'pGraph.AddElement pElement, 0
pMxDoc.ActiveView.PartialRefresh esriViewGraphics, Nothing, Nothing
End Sub
I am now in the process of writing this in JAVA.
Guy