Last updated on 2018-10-28
When working with a high-resolution monitors, like the one in the Surface Pro 3 (did I tell you how awesome this baby is?), programs need to be configured to use larger fonts, otherwise their text is completely unreadable, especially when you are presenting to someone else and don’t want them to have to come closer to your laptop when your UX comes up. One example is the Java JOptionPane
, which looked tiny every time I used it. So after some drilling in the net, found the solution (and also a way to change other parameters in the dialog). The font is derived from a global property of the UIManager
class called OptionPane.messageFont
, which is changed like this:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javax.swing.UIManager.put("OptionPane.messageFont", new Font("Segoe UI", Font.PLAIN, 25)); |
To get all the available fonts in your environment, you can run the following code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); | |
String[] fontNames = ge.getAvailableFontFamilyNames(); | |
for (int index = 0; index < fontNames.length; index++) { | |
System.out.println(fontNames[index]); | |
} |
A very long list of options that can be managed using the UIManager
can be found here.
Be First to Comment