Skip to Main Content

New to Java

Drawing Circle with End-Point of Line as Centre

User_AYF65Apr 12 2017 — edited Apr 13 2017

Hi,

I am trying to draw a circle  with centre at the end point of Line but the centre is not exactly at the the end point.

import java.applet.Applet;

import java.awt.*;

import javax.swing.*;

import java.awt.image.*;

import javax.imageio.ImageIO;

public class JCircle extends Applet{

    int x1=30;int ix1;

    int y1=30;int iy1;

    int x2=60;int ix2;

    int y2=60;int iy2;

     public  void paint(Graphics g) {

              g.drawLine(x1, y1,x2, y2);

              g.drawOval( x1, y1, 10, 10);

              g.drawOval( x2, y2, 10, 10);

             

    }

}

can some body please guide me what is the problem?

Zulfi.

circles not at end points.jpg

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 11 2017
Added on Apr 12 2017
3 comments
571 views