You want to use Java2D to draw circles / polygons to suit your needs. In the public void paint(Graphics g) method of the control you want to draw, you can draw a Graphics object. Some examples of various things that may be helpful:
//Draw a polygon public void paint(Graphics g) { int xVals[] = {25, 145, 25, 145, 25}; int yVals[] = {25, 25, 145, 145, 25}; g.drawPolygon(xVals, yVals, xVals.length); } //Draw an ellipse/circle public void paint(Graphics g) { int xPos = 50; int yPos = 50; int xWidth = 100; int yWidth = 100; g.drawOval(xPos, yPos, xWidth, yWidth); }
Keep in mind that the position for calls such as drawOval, drawRect, etc., refers to the upper left corner of the form, and not to the center of the form. If you want your oval to be centered at 50 and a width of 100, you need to set xPos and yPos to 0.
Taylorp
source share