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.
Asked
Active
Viewed 6,317 times
6
-
1Isn't this more dependent on the OS than on Java/Swing? – Hovercraft Full Of Eels May 18 '11 at 20:51
-
yes, correctly, you are right, @Jon are you tried determine what GraphicEnviroment[] returns, sure depends of number of Monitors, nomber of GPU's and cores inside GPU (profesional GPU for 3D, program for architects ...), yes if you set L&F for concrete Native OS then you can change that – mKorbel May 18 '11 at 21:01
2 Answers
6
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.
1
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.

jzd
- 23,473
- 9
- 54
- 76