Here you can find the source of setUpCellRenderer(JTable table)
public static void setUpCellRenderer(JTable table)
//package com.java2s; //License from project: Open Source License import java.awt.Component; import javax.swing.BorderFactory; import javax.swing.JTable; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.TableColumn; public class Main { public static void setUpCellRenderer(JTable table) { DefaultTableCellRenderer r = new DefaultTableCellRenderer() { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component renderer = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);/*from w w w .j a v a 2s. com*/ setBorder(BorderFactory.createEtchedBorder()); return renderer; } }; int colCount = table.getColumnCount(); for (int i = 0; i < colCount; i++) { TableColumn col = table.getColumnModel().getColumn(i); col.setCellRenderer(r); } } }