模仿JTable中行呈现的默认行为 [英] Mimic default behaviour of row rendering in a JTable

查看:108
本文介绍了模仿JTable中行呈现的默认行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java 7应用程序中,我使用带有两列的Swing JTable.左列使用DefaultTableCellRenderer,其中setHorizontalAlignment()设置为居中,而右列不使用特定渲染器.

In my Java 7 application I use a Swing JTable with two columns. The left column uses a DefaultTableCellRenderer where the setHorizontalAlignment() is set to centered, whereas the right column uses no specific renderer.

默认情况下,该右列以交替的颜色显示每个表行,而使用渲染器的左列则不是这种情况.而且,当我将鼠标悬停在右列的行上时,鼠标光标下方的行在聚焦时会突出显示,而在左列也是如此.

That right column shows each table row in alternating colors by default, which is not the case on the left column with the renderer used. Moreover, when I hover with the mouse over the rows on the right column, then the row under the mouse curser is highlighted when focused, which also isn't the case with the left column.

使用DefaultTableCellRenderer时,是否有任何(简便)的方法来模仿行渲染的默认行为(即,交替显示颜色和突出显示的行)?

Is there any (easy) way of mimic the default behaviour of the row rendering (i.e. the alternating colors and the highlighted row) when using a DefaultTableCellRenderer?

PS:我正在使用L& F.

PS: I am using the Substance L&F.

推荐答案

是否有任何(简便)的方法来模仿该行的默认行为 渲染时(即交替的颜色和突出显示的行) 使用DefaultTableCellRenderer?

Is there any (easy) way of mimic the default behaviour of the row rendering (i.e. the alternating colors and the highlighted row) when using a DefaultTableCellRenderer?

Substance具有自己的Renderer,您应在之前添加Substance来更改XxxXxxRenderer,例如 SubstanceDefaultTableCellRenderer而不是DefaultTableCellRenderer,对于JComboBoxJListJTreeJTableHeader

Substance has own Renderers, you should change XxxXxxRenderer by add Substance before, e.g. SubstanceDefaultTableCellRenderer instead of DefaultTableCellRenderer, the same for JComboBox, JList, JTree or JTableHeader

这篇关于模仿JTable中行呈现的默认行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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