Font size of JDialog title

后端 未结 2 519
南方客
南方客 2021-01-18 07:27

How do I set the font size of the title of a JDialog. I\'m displaying JDialogs on extremely high resolution monitors (5 mega pixels), and the dialog titles are not legible.

相关标签:
2条回答
  • 2021-01-18 08:03

    I don't think there is a good way to change the font size. I would suggest creating a custom dialog based on a Window that would have a larger title and a close button.

    0 讨论(0)
  • 2021-01-18 08:12

    You can play with setDefaultLookAndFeelDecorated(), but the title bar is not going to look native or like other normal dialogs, but you can try this.

        JDialog.setDefaultLookAndFeelDecorated(true);
        JDialog dialog = new JDialog(frame, "Test");
        dialog.getLayeredPane().getComponent(1).setFont(new Font("Lucida",Font.PLAIN,48));  
        dialog.setSize(300,100);  
        dialog.setLocation(400,200);  
        dialog.setVisible(true); 
    

    outputs the following

    enter image description here

    Note: the setDefaultLookAndFeelDecorated() method

    Provides a hint as to whether or not newly created JFrames should have their Window decorations (such as borders, widgets to close the window, title...) provided by the current look and feel.

    so there is no guarantee that it will work the same way on different settings, I would assume.

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