如何设置 JDialog 标题的字体大小。我在超高分辨率显示器(5 兆像素)上显示 JDialogs,但对话框标题不清晰。我需要在每个对话框的基础上执行此操作,因为该应用程序是多显示器的,一些对话框出现在较低分辨率的显示器上,而一些出现在较高分辨率的显示器上。
最佳答案
您可以尝试使用 setDefaultLookAndFeelDecorated()
,但标题栏看起来不会是原生的或不像其他普通对话框,但您可以试试这个。
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);
输出如下
注意:setDefaultLookAndFeelDecorated()
方法
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.
所以我假设不能保证它在不同的设置下会以相同的方式工作。
关于java - JDialog标题的字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6050759/