Title explains the question. How can I easily do that?
Title explains the question. How can I easily do that?
Font bigFont = new Font("sansserif", Font.PLAIN, 24); // or whatever
myTable.getTableHeader().setFont(bigFont);
This is a simple way to increase the preferredSize of the TableHeader. It will increase the height of the header, but if your column names are too long then they might not fit widthwise.
Instead of overriding JViewport.getPreferredSize like in aterai answer you can just set preferred width.
JScrollPane scroll = new JScrollPane(table2);
scroll.getColumnHeader().setPreferredSize(new Dimension(0, HEADER_HEIGHT));
JScrollPane ignores column header width, so you can safely set zero here.