Align Strings in columns in JTextArea

Output will be aligned "properly" in your JTextArea only if you use a mono-spaced font. "Andale Mono 14" for example would do the trick.

Also, in order to make your life easier and avoid the padding hell, use String.format with it's syntax.

String format = "%1$5s %2$-40s %3$-20s";
String someLine;
while (whatEver...) {
   ... 
   someLine = String.format(format, aNum, aName, aDate);
   jTextArea1.append(someLine + "\n");
}

Use a JTable instead (for what is apparently tabular information). See How To Use Tables for more details & working examples.

Table Sort Demo


You may use HTML with swing component or use JEditorPane.

JLabel jt=new JLabel();
jt.setText("<html>
            <table border='1'>
               <tr><th>No</th><th>Name</th></tr>
               <tr><td>1</td><td>Mr.A</td></tr></table></html>");