Java 如何更改 JTable 标题的字体?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4408644/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 17:08:23  来源:igfitidea点击:

How can I change the font of a JTable's header?

javafontsjtablejtableheader

提问by Stefanos Kargas

I want to set the JTable header's font. Do you know how?

我想设置 JTable 标题的字体。你知道如何?

采纳答案by dogbane

This should work:

这应该有效:

    table.getTableHeader().setFont(new Font("SansSerif", Font.ITALIC, 12));

回答by Argiropoulos Stavros

You should implement TableCellRenderer.

您应该实现 TableCellRenderer。

回答by Michel

JTableHeader header = table.getTableHeader();
header.setFont(new Font("Dialog", Font.BOLD, 18));

回答by Hossein

you can also use this to set all table's header's font :

您还可以使用它来设置所有表格标题的字体:

    UIManager.put("TableHeader.font", font1);

回答by T.A.Chathura Priyahsad

This work for me

这对我有用

tableName.getTableHeader().setFont(new Font("Segoe UI", 1 , 16));