Fantasychef
Fantasychef

Reputation: 21

text area table format

Im trying to make a table like format using a Test Area for Java, and its not work correctly as it wont be in line... But i need it to be in the correct format. This is what i currently have

textArea.setText("Name\t\tAge\tDe-Sexed\tFee\n");

textArea.append("Text");
textArea.append("\t\t25");
textArea.append("\tYes");
textArea.append("\t\t$00.00\n");

textArea.append("sfessfesf");
textArea.append("\t\t12");
textArea.append("\tFalse");
textArea.append("\t\t$00.00\n");

So the output isnt very good with the third line of the output

any idea?

Upvotes: 2

Views: 1297

Answers (1)

camickr
camickr

Reputation: 324118

You need to use a Monospaced Font for the JTextArea. Something like:

textArea.setFont( new Font("monospaced", Font.PLAIN, 12) );

Upvotes: 2

Related Questions