Here is a picture of my JTextArea:

Here is my code:
String display = "";
display = display + num + "\t\t" + name + "\t\t\t\t\t\t\t\t" +
stocks + "\t\t\t" + req +"\n";
txtArea.setText(display);
What should I do so that the texts are aligned properly regardless of the length of characters of the words?
As much as possible I want to use JTextArea not JTable (since I'm not familiar with it yet) Thank you in advanced!
Use a JTextPane instead of JTextArea, as that can do HTML. Then add an HTML <table>. Probably with some styles.
StringBuilder display = new StringBuilder("<html><table>");
display.append("<tr><td align='right'>").append(num)
.append("</td><td>").append(name)
.append("</td><td align='right'>").append(stocks)
.append("</td><td>").append(req)
.append("</td></tr>");
display.append("</table>");
txtPane.setText(display.toString());
This allows proportional fonts and styled text like bold, red, background colors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With