title: Java Swing GUI artifacts when waiting for grid to populate
body: <p>I'm making a small GUI program that fetches coordinates from a server and then paints them on a grid. The painting part works, but there are artifacts until the coordinates are finished fetching from the server. I'm guessing it has to do with the fact that I'm setting the coordinates on the grid before it is finished populating. I'm drawing the coordinates on the grid using paintComponent(Graphics g) method. I assume the way to fix this is to perhaps implement some multithreading so that the the program needs to wait for the coordinates to be populated before drawing them to the screen but I'm not sure how to go about that.</p>
  <p>Here is my setup so far:</p>
  <p>GUI: JFrame</p>
  <ul>
  <li>main method</li>
  <li>sets up GUI with components</li>
  <li>helper methods to fetch coordinates from server, parse them, and create ArrayList of Coordinates.</li>
  </ul>
  <p>Coordinates:</p>
  <ul>
  <li>POJO for holding coordinates</li>
  </ul>
  <p>Grid: JPanel</p>
  <ul>
  <li><code>paintComponent(Graphics g)</code> draws X and Y axes, <code>drawCoordinates(Graphics g)</code> draws Coordinates on screen</li>
  </ul>
  <p>How would I go about fixing these artifacts, and making sure that when the app starts up the axes are drawn and the Coordinates are drawn once the fetching from the server is finished? I tried some stuff with synchronized but I'm not sure how that works with <code>paintComponent(Graphics g)</code> as that method isn't called explicitly in the code.</p>
  <p>Thanks!!!</p>