title: Align Strings in columns in JTextArea
body: <p>I want to print Strings in JTextArea and align them properly. Its hard to explain so I will upload the screen shot of what I am trying to achieve.</p>
  
  <p><img src="https://i.stack.imgur.com/xwe3i.png" alt="Screen shot of what I have got so far"></p>
  
  <p>So Strings printed in each line are printed from Paper object which has parameters (id, title, author, date, rank). The data is read from a text file and is stored in a LinkedList using loadPaper() function.</p>
  
  <p>Then displayPapers() function is used to display content of the Paper object to the JTextArea.
  displayPapers() is listed below:</p>
  
  <pre><code>/** Print all Paper object present in the LinkedList paperList to textArea */
  public void displayPapers(){
      // clear textArea before displaying new content
      displayTxtArea.setText("");
  
      Paper currentPaper;
      ListIterator&lt;Paper&gt; iter = paperList.listIterator();
  
      while(iter.hasNext()){
          currentPaper = iter.next();
          String line = currentPaper.toString();
  
          if("".equals(line)){
              continue;
          } // end if
  
          String[] words = line.split(",");
          displayTxtArea.append   ("  " 
                                  + padString(words[0],30) 
                                  + padString(words[1],30) 
                                  + "    " 
                                  + padString(words[2],30) 
                                  + "  " 
                                  + padString(words[3],30)  
                                  + padString(words[4],30) 
                                  + "\n");
  
          System.out.println(words);
          //displayTxtArea.append(currentPaper.toString());
      } // end while
  
      displayTxtArea.append("  Total " + noOfPapers + " entries!");
  
  } // end showAllPaper
  </code></pre>
  
  <p>The padString() function adds spaces to the String so that all of them have same number of words. PadString() is listed below:</p>
  
  <pre><code>/** Add spaces to Strings so that all of the are of same number of characters
   *  @param str  String to be padded
   *  @param n    total number words String should be padded to
   * @return str  Padded string 
   */
  private String padString(String str, int n){
      if(str.length() &lt; n){
          for(int j = str.length(); j &lt; n; j++){
              str += " ";
          } // end for
      } // end if
      return str;
  } // end padString
  </code></pre>
  
  <p>I have worked on this for a while but still cant get the solution. As you can notice the above picture not everything is perfectly aligned as intended. </p>
  
  <p>How do I align them perfectly so that it looks nicer? Thanks.</p>