Font size of JDialog title

别说谁变了你拦得住时间么 提交于 2019-12-01 17:41:11
Bala R

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

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!