I'm currently working on a little Java application, that involves Swing GUIs. On my development PC everything looks fine but when I run it on my MS Surface, some icons seem to be too large for the components (or the components too small for the icons).
Here's what I mean:
Google research has lead me to conclude that this is due to Surface's high resolution and Win8's zooming to let some items appear a little larger. So I reset that zoom to 100% and it actually fixed the bad scaling.
Unfortunately, this doesn't really fix my problem. Everything is far too small without the zoom, so I'd rather not disable it. But is there any clever way to solve this? Can I just "unscale" my program's or Java's icons? Ideally, I would even like upscale the entire frame, because everything is rather small.
Edit: obviously, I've also tried just resizing the actual JFrame but it has no effect on the dialog size. I'm calling the dialog by
JOptionPane.showMessageDialog(frame, msg, "Information", JOptionPane.INFORMATION_MESSAGE);
by the way.
Here is a nasty, hacky, quick-fix solution which will stop the nasty cropping by resizing Swing's own icons to 80%.
In
main
, add this:You might want to first check whether this is actually required - Windows 8/10 defaults to 125% but some people will switch it back to 100%. I haven't found an elegant way to do this, but something along these lines will give you an idea: