Click here to Skip to main content
14,698,883 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am currently designing my System. I added a cell renderer in order to create an alternate row color on my Jtable but when I insert cell renderer in my code, JTabel selection becomes cell unlike when before I insert the code where the selection is per row. How could I make my JTable as row selection again?

(Row selection in my netbeans properties is true, while cell selection is false)

Here is the code for the cell renderer

What I have tried:

tblTable.setDefaultRenderer(Object.class, new TableCellRenderer(){
            private DefaultTableCellRenderer DEFAULT_RENDERER =  new DefaultTableCellRenderer();
            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
                Component c = DEFAULT_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
                if (row%2 == 0){
                else {
                return c;


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900