title: Draw points defined in file in Java
body: <p>I am trying to learn some of the graphics side of Java. I made a text file that lists the points and the first line in the file determines how many points there are. I need to take the points in the text file and plot them on a canvas. I have looked at several resources and I just do not understand how everything works together. I cannot even find a tutorial that gives all of the code and explains where each part goes and how it is called. Basically, I am confused by JPanels, JFrames, and basically the whole process. Below is the code that I have written so far and a screen shot of what the file looks like. </p>
  
  <p>Code:</p>
  
  <pre><code>import java.awt.*;
  import java.awt.event.*;
  import javax.swing.*;
  import javax.swing.event.*;
  import java.awt.Graphics.*;
  import java.util.*;
  import java.io.*;
  
  public class drawPoints extends JPanel
  {
  
  public void paintComponent(Graphics g)
  {
  super.paintComponent(g);
  this.setBackground(Color.WHITE);
  g.setColor(Color.BLUE);
  
  
  
    try{
  
    FileInputStream fstream = new FileInputStream("Desktop/Assign2Test1.txt");
  
  
    DataInputStream in = new DataInputStream(fstream);
    BufferedReader br = new BufferedReader(new InputStreamReader(in));
    String strLine;
  
   int i = 1;
    while ((strLine = br.readLine()) != null){
  
    final Point[] points = new Point[Integer.parseInt(br.readLine())];
  
    final String[] split = strLine.split("\u0009"); 
    points[i++] = new Point(Integer.parseInt(split[0]), Integer.parseInt(split[1])); 
  
    }
  
    in.close();
      }catch (Exception e){  System.err.println("Error: " + e.getMessage());
    }
  
  
  }
  
  
  
  
  import javax.swing.*;
  
  public class mainDrawPoint
  {
  public static void main(String args[])
    {
  
    JFrame f = new JFrame("Draw Points Application");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    drawPoints dP = new drawPoints();
    f.add(dP);
    f.setSize(500,500);
    f.setVisible(true);
    }
  }
  </code></pre>
  
  <p>All the code is doing is putting the values in an array.</p>
  
  <p><img src="https://i.stack.imgur.com/ePcur.png" alt="enter image description here"></p>
  
  <p>The x and y coordinates are separated by a tab. Any help would be appreciated!</p>