title: Java: How do I edit a JFrame using variables?
body: <p>I am fairly new to Java programming and I can't figure out why this code always produces a blank JFrame:</p>
  
  <p>mainClass.java:</p>
  
  <pre><code>import java.awt.event.MouseAdapter;
  import java.awt.event.MouseEvent;
  import javax.swing.JFrame;
  
  public class mainClass {
      public static void main(String[] args) {
          drawing d = new drawing();
  
          d.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          d.setSize(1000, 1000);
          d.setTitle("Test Game");
          d.setVisible(true);
          d.repaint();
          d.addMouseListener(new MouseAdapter() {
              public void mousePressed(MouseEvent e) {
                  d.repaint();
              }
          });
      }
  }
  </code></pre>
  
  <p>drawing.java:</p>
  
  <pre><code>import java.awt.*;
  import javax.swing.*;
  import java.util.ArrayList;
  import java.util.List;
  import java.awt.event.*;
  
  public class drawing extends JFrame implements MouseListener{
      public List&lt;units&gt; p1 = new ArrayList&lt;units&gt;();
      public List&lt;units&gt; p2 = new ArrayList&lt;units&gt;();
      JFrame frame = new JFrame();
      public void paint(Graphics g) {
          for(units u : p1) {
              g.setColor(new Color(0,0,255));
              g.drawRect(u.unitX-1, u.unitY-1, u.unitX+1, u.unitY+1);
          }
      }
      public void mousePressed(MouseEvent e) {
          int x = e.getX();
          int y = e.getY();
          p1.add(new units(x,y));
  
          boolean tryPrint = true;
  
          if(p1.size()==10 &amp;&amp; tryPrint) {
              for(units u : p1) {
                  System.out.println(u.unitX + "," + u.unitY);
              }
  
              tryPrint = false;
          }
  
          frame.repaint();
      }
  
      public void mouseClicked(MouseEvent e) {}
      public void mouseEntered(MouseEvent e) {}
      public void mouseExited(MouseEvent e) {}
      public void mouseReleased(MouseEvent e) {}
  }
  </code></pre>
  
  <p>units.java:</p>
  
  <pre><code>public class units {
      int unitX;
      int unitY;
      units(int x, int y) {
          unitX = x;
          unitY = y;
      }
  }
  </code></pre>
  
  <p>Sorry for the wordy code. I believe the issue lies somewhere in my handling of the variables or classes. Any help is appreciated.</p>
  
  <p>Also, this code is edited so that may be the reason some comments don't make sense.</p>