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
tblTable.setDefaultRenderer(Object.class, new TableCellRenderer(){ private DefaultTableCellRenderer DEFAULT_RENDERER = new DefaultTableCellRenderer(); @Override 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){ c.setBackground(Color.WHITE); } else { c.setBackground(Color.LIGHT_GRAY); } return c; } });
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)