Hello, does anyone know how i can draw a small handle (square) on the edge of the circle at each quadrant( for e.g at the north,east,west and south quadrants) I used general path to draw the circle, now I'm having difficulties to draw the handles. Here is my code:


import javax.swing.*;
import java.awt.*;
import java.awt.geom.GeneralPath;
import java.awt.geom.PathIterator;
import java.awt.geom.Rectangle2D;

public class RoundShape {

    Point[] points;
    GeneralPath circle;
    final int INC = 5;

    public RoundShape(){

    private void initPoints()
        int numberOfPoints = 360/INC;
        points = new Point[numberOfPoints];
        double x = 175.0;
        double y = 175.0;
        double r = 50.0;
        int count = 0;
        for(int theta = 0; theta < 360; theta+=INC)
            int xpt = (int)(x + r * Math.cos(Math.toRadians(theta)));
            int ypt = (int)(y + r * Math.sin(Math.toRadians(theta)));
            points[count++] = new Point(xpt, ypt);

    private void initCircle()
        circle = new GeneralPath();
        for(int j = 0; j < points.length; j++)
            if(j == 0)
                circle.moveTo(points[j].x, points[j].y);
                circle.lineTo(points[j].x, points[j].y);

    public void paintRound(Graphics2D g2d){

        Shape round=getroundShape();


     private Shape getSPointRectangle(int x, int y) {
            return new Rectangle2D.Double(x - 3, y - 3, 6, 6);

    public Shape getroundShape(){
        Shape s=circle;
        return s;




import javax.swing.*;
import java.awt.*;

public class MainRound extends JPanel {

    RoundShape rs=new RoundShape();

    public MainRound(){


    public void paintComponent(Graphics g){

        Graphics2D g2d = (Graphics2D)g;

        g2d.setStroke(new BasicStroke(15));



    public static void main(String args[]){

        MainRound mr=new MainRound();
        JFrame frame=new JFrame();


You could generalize the point generation you have in initPoints to a method that takes an angle and returns the point at that angle; it would look something like Point CreatePoint(double theta), and would make use of the code inside your for(int theta... loop. Then get points for 45, 235, 225, and 315 degrees and draw little rectangles centered on those points.

Does that sounds like what you're looking for?

Edited 3 Years Ago by gusano79

This article has been dead for over six months. Start a new discussion instead.