问题
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.
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: I am using the Substance L&F.
回答1:
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
has own Renderer
s, you should change XxxXxxRenderer
by add Substance
before, e.g.
SubstanceDefaultTableCellRenderer
instead of DefaultTableCellRenderer
, the same for JComboBox
, JList
, JTree
or JTableHeader
来源:https://stackoverflow.com/questions/19738035/mimic-default-behaviour-of-row-rendering-in-a-jtable