JTable列中的对齐日期部分以propotional字体格式化 [英] Alignment date parts in JTable column formatted in propotional font

查看:207
本文介绍了JTable列中的对齐日期部分以propotional字体格式化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使日期部分(dd,MMMM,yyyy)垂直对齐。我在日期格式的固定月份和日期问了一个问题?插入填充字母,但我发现它在比例字体的情况下没有帮助(字母的宽度不同)。例如,使用Lucida Fax字体:

I need to make the date parts (dd, MMMM, yyyy) to be vertically aligned. I asked a question at Fixed length of month and day in date format? to insert padding letters, but I found that it doesn't help in case of proportional font (the width of the letters are different). For example, with Lucida Fax font:



为不同的日期部分制作不同的标签正在考虑中,但它太手动了。如果列宽很小,很难使文本被包装....

谢谢


Making different labels for different date parts is considering but it's too manual. It's hard to make the text wrapped if the column width is small....
Thanks

推荐答案

谢谢你的回答。我找到了一个使用JTextPane作为TableCellRenderer的解决方案,然后定义了tabstop值,并在格式化日期中使用了制表符。它似乎可以满足我的要求,并且还具有普通文本字段的其他功能,例如自动换行...

Thanks for your answers. I found for myself a solution that uses JTextPane as a TableCellRenderer, then define the tabstop values, and use tabs in formatting date. It seems ok for my requirement and also have other features of normal text field such as word wrapping...

这篇关于JTable列中的对齐日期部分以propotional字体格式化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆