title: Format JTextArea in Tabular format
body: <p>I am Doing Simple text Report on <code>JTextArea</code> in <code>JApplet</code>.</p>
  
  <p>I am Trying to display this 
        <code>String</code> of Array in Table format, it's quite work well but i want <code>Integer</code> number hould   be in RightAlign and Text should be in LeftAlign.as well as please suggest me <code>JTextArea</code> is good or <code>JTextpane</code> is ? </p>
  
  <p>To make simple Text report.my next target is to get input from XML file and display as in table structure, i know its too hard to make such thing, but what they say about "Nothing is impossible". so plz someone help me to do this i am completely stuck with this. </p>
  
  <pre><code>import java.awt.Color;
  import java.awt.Container;
  import java.awt.FlowLayout;
  import java.awt.Font;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.util.MissingFormatArgumentException;
  
  import javax.swing.BorderFactory;
  import javax.swing.JApplet;
  import javax.swing.JButton;
  import javax.swing.JTextArea;
  import javax.swing.border.Border;
  
  public class MainReport extends JApplet implements ActionListener {
      String[] colName = new String[] { "Date", "Account.No", "Description",
              "Deposit", "Withdraw" };
      // here is my input of String Array.
      String a[][] = new String[][] {
              { "13/12/2013", "101", "AlphaSoftInfotekNashik", "3000", "0" },
              { "15/12/2013", "102", "Bank Ladger 2 xxxxxxxxxxxxx", "5000", "0" },
              { "16/12/2013", "103", "Accout Closing with Details", "800", "0" } };
      StringBuilder sb = new StringBuilder();
      final String Header = "%s %85s%n%n%s %10s%n";
      // final String HRule ="";
      final String format = "|%1$-30s|%2$-30s|%3$-30s|%4$-30s|%5$-35s";
      final String NumColF = "";
      String cformat = "%20s";
      String format1 = "%20s";
      String s1 = "%61s";// for spillover text
      String s2 = "%10s";
      int i, j, k;
      int Position = 0;
      boolean flag = false;
      String a1, a2;
      Container c;
  
      JTextArea outputArea;
      public static final int LINES = 10;
      public static final int CHAR_PER_LINE = 40;
      JButton b;
  
      public void init() {
          c = getContentPane();
          c.setLayout(new FlowLayout());
          outputArea = new JTextArea(30, 60);
          outputArea.setLocation(100, 100);
          outputArea.setColumns(80);
          outputArea.setLineWrap(true);
          outputArea.setWrapStyleWord(false);
          // outputArea= new JTextArea(LINES,CHAR_PER_LINE);
          // outputArea.setSize(40, 40);
          Border border = BorderFactory.createLineBorder(Color.RED);
          outputArea.setBorder(BorderFactory.createCompoundBorder(border,BorderFactory.createEmptyBorder(10, 10, 10, 10)));
          c.add(outputArea);
          b = new JButton("Show Report");
          b.addActionListener(this);
          c.add(b);
  
      }
  
      public void actionPerformed(ActionEvent e) throws MissingFormatArgumentException {
          // here i am trying to make header as well as footer//footer is not
          // created yet but its my plan to add next.
          outputArea.setEditable(false);
          outputArea.setFont(new Font("Times New Roman", Font.PLAIN, 14));
          outputArea.setText(" ");
          outputArea.append(String.format("%s %n", " "));
          outputArea.append(String.format(format, colName));
  
          for (i = 0; i &lt; a.length; i++) {
              outputArea.append("\n");
              for (j = 0; j &lt; a[i].length; j++) {
                  if (a[i][j].length() &gt; 20) {
                      a1 = a[i][j].substring(0, 20);
                      flag = true;
                      Position = j;
                      outputArea.append(a1 + String.format(s2, ' '));
                      a2 = a[i][j].substring(20);
                  } else {
                      outputArea.append(a[i][j] + String.format(cformat, ' '));
                  }
              }
              if (flag == true) {
                  outputArea.append(String.format("%n", ' '));
                  flag = false;
                  for (k = 0; k &lt; a[i].length; k++) {
                      if (k == Position) {
                          outputArea.append(String.format(s1, ' ') + a2);
                      }
                  }
              }
              outputArea.append("\n");
          }
      }
  
  }
  </code></pre>