Earlier you have read about the shading of the
rows in JTable. So, you are now capable for setting the shading the
column in JTable. In JTable component
the shading columns are the simplest way of shading alternate columns in JTablecomponent
that overrides the prepareRenderer() method. The following code helps
you for setting the shading columns in JTable.
Description of program:
First of all the given code creates a table with specified column with headers by using
JTableHeader that contains some data in it. The background color of the column header is yellow and the text color is black. After this, you need to shade the alternate columns (Odd place's row) in JTable component that overrides the
prepareRenderer() method. The table calls the prepareRenderer method for every cell that is used to display and override method calls the super class and retrieves the
prepareRenderer components. Then you have to get a colorful column of JTable.
Here is the code of program: