title: How to delete a drawn string in JFrame
body: <p>So basically I want to have a number system on a JFrame panel. The number is displayed on the frame using this method.</p>
  
  <pre><code>public static void text(int x, int y, String text)
  {
  if (instance == null)
    throw new RuntimeException("Must call window method first");
  Graphics g = image.getGraphics();
  g.setColor(color);
  Font font = new Font(null, Font.PLAIN, fontSize);
  g.setFont(font);
  FontMetrics metrics = g.getFontMetrics();
  int actualX = x - metrics.stringWidth(text) / 2;
  int actualY = y + metrics.getAscent() / 2;
  g.drawString(text, actualX, actualY);
  
  instance.repaint();
  }
  </code></pre>
  
  <p>When the value of the number increases I want it to replace the number up there with the new number. I know there has to be a way to do this but could someone help me with finding it? Thanks so much.</p>