开发者

How to align text appended to a JScrollPane

I think the screenshot is worth a couple of paragraphs

How to align text appended to a JScrollPane

The best way I can think of doing it is to check for the length of the string an开发者_StackOverflowd depending give/take \t, but it just seems inelegant. Is there a simpler/better way?


I would use a JTable for this. You can put one in a JScrollPane. This will get you aligned columns automatically. Plus you will get column headers which will aid in understanding what the data means.


If you want to stick with plain text and have an upper bound on the length of fields (which you'd need to guarantee alignment), then you could use printf.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜