1

I have a problem with the resolution. I developed the Java Swing Application (Desktop App) which is working fine but the problem comes when I start using that app with different laptop or desktop systems where every system have its own resolution because of which the Components on JFrame are getting bigger and smaller and biggest problem comes when I start using that app with the 4K resolution systems where you cannot see anything because everything on that JFrame becomes too small and you won't be able to read anything. Do we have any resolution for this?

Saurabh
  • 37
  • 1
  • 6
  • are you using layout manager? –  Apr 08 '16 at 13:49
  • Some code to demonstrate the issue, a [mcve], would help us understand what the problem is. As you state it, we can't say for sure. You may be setting the sizes directly instead of letting Swing do so automatically, for example. But without code, there is no way of knowing. – RealSkeptic Apr 08 '16 at 13:50
  • So the layout is GridLayout which is working. So whatever resolution you will set it will arrange the components accordingly but it will not increase/decrease the font size. That's the problem – Saurabh Apr 08 '16 at 13:55

2 Answers2

0

It sounds like you're having issues with the lack of HiDPI support in Java on Windows or Linux for Swing/AWT. This is slated to be fixed in Java 9, and you can probably test it out with one of the latest alpha builds.

The LookAndFeels currently just don't support the scaling necessary to work properly in HiDPI environments automatically. You'll need to manually resize/scale your text/components/windows until Java 9 is available, or switch to JavaFX.

Here's an example of how to increase font size manually.

Community
  • 1
  • 1
Darth Android
  • 3,437
  • 18
  • 19
0

Thats how all applications behave. GUI elemens' size is defined in pixels, if display's resolution becomes bigger, it will have more pixels and the relative GUI elements' size will decrease. Thats why Windows (and possibly other systems) have an option to set a dpi scaling otherwise everything looks too small.

There is an interesting bug though - Swing is by default claiming that it is DPI aware, so windows doesn't scale it. There are ways to change that behaviour though. If Windows has scaling enabled then your app will look smaller on high resolution screens than other native applications. This is especially sad as swing actually does not support DPI scaling and the only option to make do something about it - is to manually change font sizes How to set the DPI of Java Swing apps on Windows/Linux?

Community
  • 1
  • 1
black
  • 357
  • 3
  • 18