Hi how to set gradient background to column header ? I have Jtable:
JTable table = new JTable(4, 5);
and try to setColor: table.getTableHeader().setBackground(Color.blue);
but with no succes color of column header is still same and these is just one color and I need gradient
thx for help
Are you coding this with NetBean’s code generation or are you coding your Swing by hand?
Have you tried creating a class that extends the JTableHeader and overrides its paintComponent method? Give it a try and in that method create a GradientPaint object or one of its variants use it to set the Graphics2D paint’s property and then call fillRect using the current dimensions of the component to fill it with gradient color.
For example here are two ways to do this, one with a custom JTableHeader and one with a custom cell renderer that is used by the table header: