// -*- mode:java; encoding:utf-8 -*-
// vim:set fileencoding=utf-8:
// @homepage@

package example;

import java.awt.*;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;

public final class MainPanel extends JPanel {
  private MainPanel() {
    super(new BorderLayout());
    String[] columnNames = {"String", "Integer", "Boolean"};
    Object[][] data = {
      {"aaa", 12, true}, {"bbb", 5, false},
      {"CCC", 92, true}, {"DDD", 0, false}
    };
    TableModel model = new DefaultTableModel(data, columnNames) {
      @Override public Class<?> getColumnClass(int column) {
        return getValueAt(0, column).getClass();
      }
    };
    JTable table = new JTable(model);
    table.setAutoCreateRowSorter(true);

    TableColumn tableColumn = table.getColumnModel().getColumn(0);
    // tableColumn.setHeaderRenderer(new HeaderRenderer());
    Font font = new Font(Font.SANS_SERIF, Font.PLAIN, 32);
    tableColumn.setHeaderRenderer((tbl, value, isSelected, hasFocus, row, column) -> {
      TableCellRenderer r = tbl.getTableHeader().getDefaultRenderer();
      JLabel l = (JLabel) r.getTableCellRendererComponent(tbl, value, isSelected, hasFocus, row, column);
      l.setFont(font);
      return l;
    });

    // all column
    // table.getTableHeader().setFont(font);

    add(new JScrollPane(table));
    setPreferredSize(new Dimension(320, 240));
  }

  public static void main(String[] args) {
    EventQueue.invokeLater(MainPanel::createAndShowGui);
  }

  private static void createAndShowGui() {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
      ex.printStackTrace();
      Toolkit.getDefaultToolkit().beep();
    }
    JFrame frame = new JFrame("@title@");
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.getContentPane().add(new MainPanel());
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
}

// class HeaderRenderer implements TableCellRenderer {
//   private final Font font = new Font(Font.SANS_SERIF, Font.PLAIN, 32);
//
//   @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
//     TableCellRenderer r = table.getTableHeader().getDefaultRenderer();
//     JLabel l = (JLabel) r.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
//     l.setFont(font);
//     return l;
//   }
// }

@@ -1199,35 +1199,29 @@
 ;%0A      
-JLabel l = (JLabel)
+Component c =
  r.getTa
@@ -1295,25 +1295,25 @@
 umn);%0A      
-l
+c
 .setFont(fon
@@ -1329,17 +1329,17 @@
  return 
-l
+c
 ;%0A    %7D)
@@ -2543,27 +2543,21 @@
     
-JLabel l = (JLabel)
+Component c =
  r.g
@@ -2642,17 +2642,17 @@
 %0A//     
-l
+c
 .setFont
@@ -2673,17 +2673,17 @@
  return 
-l
+c
 ;%0A//   %7D

remove redundant cast