When I append the data to the JTextArea in Java it does not copy the alignment.
CodePudding user response:
There could be 2 problems at hand. If your original textfile is using Tabs instead of spaces to align its columns the way it does, you need to set the same tab size on your JTextArea
component.
See JavaDoc for setTabSize(int)
Secondly, alignment can only really be achieved with a mono-sapced font (where every character has the same visual width).
I just found this answer by Guillaume Polet where he describes the way to get a general-purpose monospace font by simply specifying monospaced
as the font's name:
JTextArea textArea = new JTextArea(24, 80);
textArea.setFont(new Font("monospaced", Font.PLAIN, 12));