Java Swing - How to change the font size on a JPanel's TitledBorder?

前端 未结 1 1991
独厮守ぢ
独厮守ぢ 2021-01-02 23:51

I need to be able to programmatically change the font size of all the components in my Swing app. I cannot do this in the usual ways (with UIManager or putClientProperty) as

相关标签:
1条回答
  • 2021-01-03 00:35

    The following worked for me:

        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        ((javax.swing.border.TitledBorder) jPanel1.getBorder()).
            setTitleFont(new Font("Arial", Font.ITALIC, 14));
    
        jPanel1.repaint();
    }
    

    I've tested this in NetBeans 6.9.1enter image description here

    0 讨论(0)
提交回复
热议问题