title: Swing - Adding line to exiting Panel doesn't show up
body: <p>I have a JPanel with points drawn at start. I am trying to add lines between these points, as I traverse between these points. But lines do not show up. If I use repaint, previous drawing goes away. Below is my code. Do I need to refresh something in the drawLine code?</p>
  
  <pre><code>public void paintComponent(Graphics g) {
      super.paintComponent(g);
      doDrawing(g);
  }
  //works fine
  private void doDrawing(Graphics g) {
      g.drawLine(x, y, x, y);
  }
  
  //called later from outside, lines do not show up on Panel
  public void drwaLine(Point p1, Point p2) {
      Graphics g2d = getGraphics();
      g2d.drawLine(p1.getX(), p1.getY(), p2.getX(), p2.getY());
  }
  </code></pre>