You can simply extend the DefaultTableCellRenderer and make it look from the interface that the cell is not “focused”.
I removed the border using the following renderer:
private static class BorderLessTableCellRenderer extends DefaultTableCellRenderer { private static final long serialVersionUID = 1L; public Component getTableCellRendererComponent( final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int col) { final boolean showFocusedCellBorder = false;
You can install it on your JTable as follows:
table.setDefaultRenderer( Object.class, new BorderLessTableCellRenderer() );
or, for strings:
table.setDefaultRenderer( String.class, new BorderLessTableCellRenderer() );
A little hack that it just reuses the original renderer and pretends that the focused / selected cell is not there, but it should start you.
source share