Reputation: 491
lines like this:
id title price quantity sum 001 c++ primer 20.0 5 100.0
I want the two lines look like the above .The first line is the head.
And lines below are information about books. I try to use blanks to achice it,
but it's not that good.can you help?thank you.
Upvotes: 1
Views: 964
Reputation: 324118
The better choice is to use a JTable. Read the section from the Swing tutorial on How to Use Tables for more information and working examples.
If you must use a JTextArea, then you need to use a monospaced font.
textArea.setFont( new Font("monospaced", Font.PLAIN, 10) );
or any other font that that has a fixed size for each character.
Upvotes: 1
Reputation: 13728
I would use a JEditorPane here with "text/html" content type and make an HTML table.
Upvotes: 0
Reputation: 29550
Of course, you have to use a fixed-width-font. But detecting one which works for all characters is not trivial (or impossible?), because, e.g., Asian characters usually are two latin characters wide.
Upvotes: 0