JDialog标题的字体大小 [英] Font size of JDialog title

查看:227
本文介绍了JDialog标题的字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置JDialog标题的字体大小.我正在极高分辨率的监视器(5兆像素)上显示JDialogs,并且对话框标题不清晰.我需要在每个对话框的基础上执行此操作,因为该应用程序是多监视器,并且某些对话框显示在较低分辨率的监视器上,而某些对话框显示在较高分辨率的监视器上.

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. I need to do this on a per dialog basis because the application is multi-monitor, and some dialogs appear on lower resolution monitors, and some on higher resolution monitors.

推荐答案

您可以使用setDefaultLookAndFeelDecorated()进行游戏,但是标题栏看起来不会像本地对话框或其他普通对话框,但是您可以尝试使用此方法.

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); 

输出以下内容

注意:setDefaultLookAndFeelDecorated()方法

提供有关是否 新创建的JFrames应该具有 他们的橱窗装饰(例如 边框,关闭窗口的小部件, 标题...)由当前外观提供 和感觉.

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.

这篇关于JDialog标题的字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆