Question: When I draw lines in my program the position is perfect, but when I use those same coordinates for a square or oval they are way off the mark. My code is:

```
g2d.drawRect(one1, one2, two1, two2);
g2d.drawOval(one1, one2, two1, two2);

```

And the points are gather by:

```
one1 = (int)e.getX();
one2 = (int)e.getY();

```

This is a follow on to a [question I previously asked](https://stackoverflow.com/questions/8479432/lines-arent-drawing-exactly-where-i-clicked).

Answer: 
Alright, I got what your problem is. If you see the below image, the way that the parameters taken by oval and sqaure are different from the line.

To draw a line --> You will have to specify the starting point and the ending point. Just passing them directly to the Graphics object would do the job for you. However for a Square or Oval, it is different. You first click will grab a point and then you should do some manipulation on what should be the output when you do the second click. The second click should not be considered as a co-ordinate into the drawOval() or drawRect() methods directly.

Because the Parameter for these methods are 

```
x, y, width, height

```

Whereas you are getting

```
x1, y1  and x2, y2

```

![enter image description here](https://i.stack.imgur.com/lyEdU.png)

```
package sof;

import java.awt.Color;
import java.awt.Graphics;

import javax.swing.JComponent;
import javax.swing.JFrame;

public class DrawTest {
    public static void main(String[] args) {
        JFrame frame = new JFrame("Draw Test");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(new MyComponent());
        frame.setSize(260, 280);
        frame.setVisible(true);
    }
}

class MyComponent extends JComponent {
    public void paint(Graphics g) {
        int height = 120;
        int width = 120;
        g.setColor(Color.black);
        g.drawOval(60, 60, width, height);
        g.drawRect(60, 60, width, height);
        g.drawLine(0,0,50,50);
    }
}

```
My guess is that you're capturing the X & Y coordinates for a container (say 200,200) then creating the oval/rect within a NEW container; you state a JLabel above in your comment.

If you're capturing X & Y to be 200,200 for a JPanel, then creating a JLabel and assigning the component an X/Y of 200,200 it is the coordinate within its new component, not the parent in which you captured the X/Y.

Can you post the code where the MouseListener is initiated as well as when the JLabel is created if this is wrong? As others have said we need more code to work from. An image example would be equally beneficial!