Moving 2d shapes altogether at once JAVA
<p>I have a java project that I can't quite seem to figure out right now. </p>

<p>It wants us to create a composite object made up of 2D shapes from a package called Wheels. </p>

<p>This composite object needs to take in <code>mouseEvent</code>s in order to move together when clicked and dragged on. I've already completed this part but the next part of the assignment requires us to have one part of that object to be independently drag-able such that when you drag it, the whole composite object does not move. </p>

<p>Although when you drag the composite object, the independent object should move the same amount maintain position relative to the composite object.</p>

<p>Here's the class that I think would need some working on.</p>

<pre><code>public Character(Color _color1, Color _color2)
{
    _indPart1 = new IndPart(); // head
    _charPart2 = new CharacterPart(this); // body
    _charPart3 = new CharacterPart(this); //left arm
    _charPart4 = new CharacterPart(this); //right arm
    this.setColor(_color1, _color2);
    _indPart1.setSize(50, 50);
    _charPart2.setSize(50, 100);
    _charPart3.setSize(75, 35);
    _charPart4.setSize(75, 35);
}

public void setLocation(int x, int y)
{
    _x = x;
    _y = y;
    //_indPart1.setLocation((_x - _otherPointx) + (x - 300), (_y - _otherPointy) + (y - 250)); // head
    _indPart1.setLocation(x, y - 50); // head
    _charPart2.setLocation(x, y); //body
    _charPart3.setLocation(x + 51, y); // right arm
    _charPart4.setLocation(x - 76, y); // left arm
}

@Override
public void mousePressed(MouseEvent e)
{
    _prevPoint = e.getPoint();
}

@Override
public void mouseDragged(MouseEvent e) 
{
    _currPoint = e.getPoint();
    //_otherPointx = _indPart1.getXLocation();
    //_otherPointy = _indPart1.getYLocation();
    _diffx = _currPoint.x - _prevPoint.x;
    _diffy = _currPoint.y - _prevPoint.y;
    this.setLocation(_x + _diffx, _y + _diffy);
    _prevPoint = _currPoint;
    //_otherPointx = _currPoint.x;
    //_otherPointy = _currPoint.y;
}

public void setColor(Color c1, Color c2)
{
    _indPart1.setColor(c1);
    _charPart2.setColor(c2);
    _charPart3.setColor(c1);
    _charPart4.setColor(c1);
}
</code></pre>
