JDialog Title Font Size

How to set font size of JDialog header. I show JDialogs on monitors with very high resolution (5 megapixels), and the names of the dialogs are not legible. I need to do this for each dialog box, because the application is a multimonitor, and some dialogs appear on lower resolution monitors, and some on higher resolution monitors.

+4
source share
2 answers

You can play with setDefaultLookAndFeelDecorated() , but the title bar will not look like a native or 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); 

displays the following

enter image description here

Note: setDefaultLookAndFeelDecorated() method

Provides a hint about whether the newly created JFrames should have their window decorations (e.g. borders, widgets to close the window, name ...) provided by the current look and feel.

therefore there is no guarantee that it will work the same in different settings, I would assume.

+4
source

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

+1
source

All Articles