views:

393

answers:

2

I have a Java application using the Substance LookAndFeel with Windows as the the target platform and I want to increase the DPI setting of my application without changing the system setting.

I want to do this because I don't want to force the user to restart Windows and because many Windows applications seem to have problems with very high DPI settings (> 120)

PS: I'm aware that the Substance LaF allows to scale the font size at runtime, but that way only the height of my controls are scaled, not the width. I want my GUI fully scaled as it would happen if I set the system's DPI setting.

+2  A: 

Don't know if that is possible. The look&feel would have to support it, and as far as I know, the Windows Look&Feel does not. Here's a hack which you may consider: Iterate through all the fonts defined in your look&feel and redefine them to be slighly bigger. Here is a code snippet that does this:

for (Iterator i = UIManager.getLookAndFeelDefaults().keySet().iterator(); i.hasNext();) {
    String key = (String) i.next();
    if(key.endsWith(".font")) {
     Font font = UIManager.getFont(key);
     Font biggerFont = font.deriveFont(2.0f*font.getSize2D());
     // change ui default to bigger font
     UIManager.put(key,biggerFont);
    }
}

I suppose you could take this one step further and redefine scale borders proportionally as well, but that gets very complicated very quickly

Joel Carranza
Best answer so far :)
DR
If your `UIManager` has keys which aren't `Strings`, then this will throws a `ClassCastException`.
uckelman
A: 

So the actual answer seems to be: no you can't. That really is a bummer because it's a pain to test.

Epaga