@Override public void mouseDragged(MouseEvent e) { last = e.getPoint(); // Save cursor position if (buttonState == MouseEvent.BUTTON1) { if (tempElement == null) { // Is there an element? tempElement = Element.createElement( // No, so create one theApp.getWindow().getElementType(), theApp.getWindow().getElementColor(), start, last); } else { tempElement.draw(g2D); // Yes – draw to erase it tempElement.modify(start, last); // Now modify it } tempElement.draw(g2D); // and draw it } }