This is called whenever I want to draw a shape to a JPanel. However, everytime it is done, the panel removes all previous drawings, which is not what I intended to be. How do I do it?Code:class ShapePanel extends JPanel { Shape currentShape; public void setShape(Shape shape) { currentShape = shape; repaint(); } public void update(Graphics g) { paint(g); } public void paintComponent(Graphics g) { super.paintComponent(g); if (currentShape != null) currentShape.draw(g); } }




Reply With Quote