title: reading from file and showing in textarea java
body: <p>I have the following code which reads names from the test file, which works fine</p>
  
  <pre><code>public class Names {
  
      Scanner scan;
      static String Firstname;
      static String Surname;
      static String Fullname;
  
      public void OpenFile()
      {
          try
          {
              scan = new Scanner(new File("test.txt"));
              System.out.println("File found!");
          }
  
          catch(Exception e)
          {
              System.out.println("File not found");
          }
      }
  
      public void ReadFile()
      {
          while(scan.hasNext())
          {
              Firstname = scan.next();
              Surname = scan.next();
              Fullname =  Firstname + " " + Surname;
  
              System.out.println(Fullname);
          }
      }
  
      public void CloseFile()
      {
          scan.close();
      }
  }
  </code></pre>
  
  <p>Then I have this main class which calls the Names class. it works fine apart from it only shows the last names from the test file.</p>
  
  <pre><code>public class NameSwing implements ActionListener {
  
      private JTextArea tf = new JTextArea(20,20);
      private JFrame f = new JFrame("names");
      private JButton b = new JButton("view");
  
      static String fullName;
  
      public NameSwing(){
          f.add(new JLabel("Name"));
          tf.setEditable(true);
          f.add(tf);
  
          b.addActionListener(this);
          f.add(b);
  
          f.setLayout(new FlowLayout());
          f.setSize(300,100);
          f.setVisible(true);
  
      }
  
      @Override
      public void actionPerformed(ActionEvent e)
      {
          if(e.getSource()==b)
          {
              tf.setText(fullName);
          }
      }       
  
      public static void main(String[] args) throws FileNotFoundException, IOException {
          NameSwing nameSwing = new NameSwing();
  
          Names t = new Names();
          t.OpenFile();
          t.ReadFile();
          t.CloseFile();
  
          fullName = Names.Fullname;   
      }
  
  }
  </code></pre>
  
  <p>This is the test file content.</p>
  
  <p>Nick Harris</p>
  
  <p>Olly Dean</p>
  
  <p>Emma Sammons</p>
  
  <p>Henry Blackwell</p>
  
  <p><strong>How can I get the textarea to show all of the names from the reader, and not just the last name?</strong></p>