Question

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.

Was it helpful?

Solution

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 Renderers, you should change XxxXxxRenderer by add Substance before, e.g. SubstanceDefaultTableCellRenderer instead of DefaultTableCellRenderer, the same for JComboBox, JList, JTree or JTableHeader

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top