public void paintComponent(Graphics g) {
    super.paintComponent(g);

    File f = new File("Data.txt");

    try {

      textArea.setText("");
      reader = new BufferedReader(new FileReader(f));

      String str = "";
      while (!(str = reader.readLine()).equals("")) {
        textArea.append(str + "\n");
      }
      reader.close();

    } catch (Exception e) {
      System.out.println(e);
    }

    repaint();
  }