开发者

How to align text appended to a JScrollPane

开发者 https://www.devze.com 2023-02-18 17:59 出处:网络
I think the screenshot is worth a couple of paragraphs 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 see

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

精彩评论

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

关注公众号