简体   繁体   English

使用JTattoo外观时如何更改JTable标头字体

[英]How to change JTable header font when using JTattoo look and feel

I use JTattoo look and feel in my project. 我在项目中使用JTattoo外观。 I try to change font of table heading using the following code: 我尝试使用以下代码更改表标题的字体:

tbExpense.getTableHeader().setFont(new java.awt.Font("Kerala", 1, 14));

But it is not working. 但它没有用。

my code 我的代码

following code for internal frame, i apply jtatto look and feel in Mainframe. 下面的内部框架代码,我在大型机中应用jtatto外观。 this is the subframe. 这是子帧。 all other components in the frame changed to jtattoo look and feel but i cant change the jtable header font 框架中的所有其他组件均更改为jtattoo外观,但我无法更改jtable标头字体

public class T extends javax.swing.JInternalFrame {
public T() {
    initComponents();
    tb.getTableHeader().setFont(new java.awt.Font("Kerala", 1, 14));
    tb.getTableHeader().repaint();
}
private void initComponents() {
    jScrollPane1 = new javax.swing.JScrollPane();
    tb = new javax.swing.JTable();
    setClosable(true);
    setTitle("Hai");
    setVisible(true);
    tb.setModel(new javax.swing.table.DefaultTableModel(
        new Object [][] {
            {null, null, null, null}, 
        },
        new String [] {
            "Title 1", "Title 2", "Title 3", "Title 4"
        }
    ));
    jScrollPane1.setViewportView(tb);
    setBounds(0, 0, 461, 372);
}                                         
  private javax.swing.JScrollPane jScrollPane1;
  private javax.swing.JTable tb;                   }

试试看

UIManager.put("TableHeader.font",new Font("Arial", Font.BOLD, 18) );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM