How do I fix this button to work like the insturctions?
<p>I'm trying to edit a method based on these instructions:</p>

<p>Change: The object clicked takes on the attributes (lineColor, fillColor, filled) currently stored in the model. If two objects overlap, change the last object drawn under the mouse.</p>

<p>The method that I am referring to:</p>

<pre><code>public void mousePressed(MouseEvent e) {

 if (model.getAction() == Model.Actions.CHANGE) {
        selectedInstance = model.getSelectedInstance(e.getX(), e.getY());
        if (selectedInstance != -1) {
            startX = e.getX();
            startY = e.getY();
            shape.add(selectedInstance, model.createShape(selectedInstance));
            if (shape.get(selectedInstance) != null) {
                shape.get(selectedInstance).setX(e.getX());
                shape.get(selectedInstance).setY(e.getY());
            }
        }
    }
    model.getContainer().repaint();
}


public void MouseDragged(MouseEvent e) {

 if (model.getAction() == Model.Actions.CHANGE &amp;&amp; selectedInstance != -1) {

            shape.get(selectedInstance).setX(Math.min(startX, e.getX()));
            shape.get(selectedInstance).setY(Math.min(startY, e.getY()));

            if (true) {

                ( shape.get(selectedInstance)).setWidth(Math.abs(startX - e.getX()));
                ( shape.get(selectedInstance)).setHeight(Math.abs(startY - e.getY()));
            }
        }
    }
</code></pre>
