How to change JTable row height globally?

后端 未结 1 1536
太阳男子
太阳男子 2021-01-12 19:58

I\'m using Nimbus L&F. I\'m trying to change font size globally for all JTable by using the following code:

NimbusLookAndFeel nimbus = new NimbusLookAnd         


        
相关标签:
1条回答
  • 2021-01-12 20:36

    Basically, there is nothing by intention. The relevant code-comment in BasicTableUI:

    // JTable's original row height is 16.  To correctly display the
    // contents on Linux we should have set it to 18, Windows 19 and
    // Solaris 20.  As these values vary so much it's too hard to
    // be backward compatable and try to update the row height, we're
    // therefor NOT going to adjust the row height based on font.  If the
    // developer changes the font, it's there responsability to update
    // the row height.
    

    On the bright side, some LAFs like f.i. Nimbus respect a ui property for rowHeight:

    UIManager.put("Table.font", new FontUIResource(new Font("SansSerif", Font.PLAIN, 28)));
    // here simply the font height, need to do better 
    int height = 28;
    UIManager.put("Table.rowHeight", height); 
    
    0 讨论(0)
提交回复
热议问题