title: JFrame displaying black screen with a little white rectangle in the top right
body: <p>I'm creating a program that reads a text file with a series of x/y coordinates and places a small square where each of them should go. The program also has to deal with another text file which has a series of x/y coordinates and a double value which represents a signal strength in decibels. When I go to launch to the program it displays a black screen with a small white rectangle in the top left corner. What is wrong with my code? I'm not getting any errors in the console. The problem is almost certainly in my coveRage.java file in the second main for loop.</p>
  
  <p><a href="https://i.stack.imgur.com/pVlIc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pVlIc.png" alt="what the program displays"></a></p>
  
  <p>first text file...</p>
  
  <pre><code>500.0 500.0
  250.0 250.0
  </code></pre>
  
  <p>second text file</p>
  
  <pre><code>1000.0 2500.0 -143.2
  1213.0 2132.0 -100.7
  </code></pre>
  
  <p>Main.java</p>
  
  <pre><code>public class Main {
      public static void main(String[] args) throws FileNotFoundException {
          File towers = new File("towers.txt");
          File readings = new File("readings.txt");
          //System.out.println(new File(".").getAbsoluteFile());
          Scanner towers1 = new Scanner(towers);
          Scanner readings1 = new Scanner(readings);
          ArrayList&lt;Integer&gt; towerPos = new ArrayList&lt;Integer&gt;();
          ArrayList&lt;Integer&gt; readingPos = new ArrayList&lt;Integer&gt;();
  
          while(towers1.hasNextDouble()) {
              towerPos.add((int)towers1.nextDouble());
          }
          towers1.close();
  
          while(readings1.hasNextDouble()) {
              readingPos.add((int)readings1.nextDouble());
          }
          readings1.close();
  
  
          JFrame f = new JFrame("Cellphone Coverage");
          f.setVisible(true);     
          f.setSize(500, 500);
          f.setDefaultCloseOperation(
              JFrame.EXIT_ON_CLOSE);
          f.add(new CoveRage(towerPos, readingPos));
  
      }
  }
  </code></pre>
  
  <p>coveRage.java</p>
  
  <pre><code>public class CoveRage 
  extends JComponent {
  
      private ArrayList&lt;Integer&gt; readingPos;
      private ArrayList&lt;Integer&gt; towerPos;
      ArrayList&lt;Integer&gt; towerPosis = new ArrayList&lt;Integer&gt;();
      ArrayList&lt;Integer&gt; distances = new ArrayList&lt;Integer&gt;();
      int xAxis;
      int yAxis;
  
      public CoveRage(ArrayList&lt;Integer&gt; towerPos, ArrayList&lt;Integer&gt; readingPos) {
           this.towerPos = towerPos;
           this.readingPos = readingPos;
          }
  
      public void paintComponent(Graphics g) {
          Graphics2D g2 = (Graphics2D) g.create();
          for (int j = 0; j &lt; towerPos.size(); j += 2) {
              int xAxis = towerPos.get(j) / 10;
              int yAxis = towerPos.get(j + 1) / 10;
              towerPosis.add(xAxis); // adds to list for checking distance between tower and signal
              towerPosis.add(yAxis);
              g2.setColor(Color.black);
              g2.fillRect(xAxis, yAxis, 5, 5);
          }
  
          for (int i = 0; i &lt; readingPos.size(); i =+ 3) { // for there are still readings left take in 3 values and repeat
              int xAxiss = readingPos.get(i) / 10; // grabs x axis of reading
              int yAxiss = readingPos.get(i + 1) / 10; // grabs y axis of reading
              int sigNal = readingPos.get(i + 2); // grabs signal strength of reading
                  for (int k = 0; k &lt; towerPosis.size(); k=+2) { // for there are still readings in towerPosis 
                      int distance = (int) Math.sqrt(Math.pow(towerPosis.get(k)-xAxiss, 2)+(Math.pow(towerPosis.get(k + 1)-yAxiss, 2))); // calulates distance between tower and reading
                      distances.add(distance); // add distance to arrayList
                      int leastDist = distances.get(0);
                      for (int u = 0; u &lt; distances.size(); u++) { // for there are still distance
                          if (distances.get(u) &lt; leastDist) {
                              leastDist = distances.get(u);
                          }
                          int expected = (int) ((int) 40*(Math.log10(1.0/leastDist)));
                          if (sigNal &gt;= expected) {
                              g2.setColor(Color.green);
                              g2.fillRect(xAxiss, yAxiss, 5, 5);
                          } else if (sigNal &lt;= expected - 9) {
                              g2.setColor(Color.red);
                              g2.fillRect(xAxiss, yAxiss, 5, 5);
                          }
                      }
              }
          }
      }
  }
  </code></pre>