title: Trying to draw lines with JPanel
body: <p>I am trying to draw lines using <code>JPanel</code> and I have hit somewhat of a wall. I can get two sides down but once it comes to subtracting from the x cord it all goes wrong. </p>
  
  <p><img src="https://i.stack.imgur.com/swZXA.png" alt="lines i&#39;m tring to draw"></p>
  
  <pre><code>package GUIstuff;
  import java.awt.Graphics;
  import javax.swing.JPanel;
  
  public class DrawPanel extends JPanel{
  
  public void paintComponent (Graphics g){
  
      super.paintComponent(g);
  
      int width = getWidth();
      int height = getHeight();
  
      int drawCounter = 0; // counters for all the while statements 
      int drawCounter2 = 0;
      int drawCounter3 = 0;
      int drawCounter4 = 0;
  
  
  
      int x1 = 0; // cords change with the while statemetns
      int x2 = 0;
      int y1 = 0;
      int y2 = 0;     
      while (drawCounter &lt;= 15){ // counter 
      y2 = 250;
      g.drawLine(x1, y1, x2, y2);
      x2 = x2 + 15;
      y1 = y1 + 15;
      drawCounter++;  } 
  
  
      int u1 = 0;
      int u2 = 0;
      int v1 = 0;
      int v2 = 0;
      while (drawCounter2 &lt;= 15){
      u2 = 250;
      g.drawLine(u1, v1, u2, v2);
      u1 = u1 + 15;
      v2 = v2 + 15;
      drawCounter2++; 
      }
  
      int a1 = 0;
      int a2 = 0;
      int b1 = 0;
      int b2 = 0;
  
      while (drawCounter3 &lt;= 15){
      a2 = 250;
      g.drawLine(a1, b1, a2, b2);
      b1 = b1 + 15;
      a2 = a2 - 15;
      drawCounter3++;
  
      }
   }
  }
  </code></pre>
  
  <p>Here is my runner class </p>
  
  <pre><code>package GUIstuff;
  import javax.swing.JFrame;
  
  
  public class DrawPanelTest {
  
  public static void main (String args[]){
  
      DrawPanel panel = new DrawPanel();
  
      JFrame application = new JFrame();
  
      application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
      application.add(panel);
      application.setSize (250, 250);
      application.setVisible(true);
  
  
  }
  
  }
  </code></pre>
  
  <p>I have a the lines in the bottom left and the upper right but when I try to subtract from x I just get lines going a crossed the whole box.</p>