开发者

JTable - cell editor is not high enough to fit the text

I'm using standart JTable with standart cell editor to edit string values. On some platforms, when cell editor is opened, text doesn't fit in it and part of the text is cut. For example "_" symbol is not visible, as well as it's hard to distingush "开发者_如何学运维l" and "1" because the upper part of the symbol may be cut.

Probably I should just increase the cell height, but how much?

The result very depends on current Look & Fell, for example on Windows everything may be fine, but on Linux described effect appear.


You can calculate row height using table's font height.

FontMetrics metrics = table.getFontMetrics(); 
int fontHeight = metrics.getHeight();
table.setRowHeight( fontHeight + delta );

delta can be anything you're comfortable with :)


You can modify the Font use by your cell editor.

Font font = new Font("Helvetica", Font.PLAIN, 22);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜