This content has been marked as final. Show 4 replies
First thing that comes to mind:
This would work for a single cell, but would repeat the graident pattern for each cell in a selected row.
1. Create a custom component that can rend a gradient back ground. I recomend subclassing JLabel and overiding printComponent(Graphics g).
2. Create a cellRenderer that returns a normal JLabel for a non selected row and your custom JLabel for a selected row.
Sure! Subclass DefaultTableCellRenderer or roll your own TableCellRenderer. Overirde paintComponent or paint
and use GradientPaint...
1. Create a custom component that can rend a gradientMake that paintComponent. Woops!
back ground. I recomend subclassing JLabel and
overiding printComponent(Graphics g).
how is it possible to make a gradient background color for the selected row in a JTable?If you want a gradient for individual cells then you would create a custom renderer as advised above.
If you want a gradient that changes for the entire row from the first to last column then you would need to make all your renderers non-opaque and then add custom painting in the JTable paintComponent(...) method.