jadrijan
jadrijan

Reputation: 1446

Java application automatically resize to fit screen resolution

The touch-screen application I am developing will be used on different screen resolutions. I never had to worry about this before, but now I do. I am wondering how can I design the GUIs so that EVERY object on the GUI resizes proportionally to fit the screen resolution? Can you refer me to a good tutorial page? I am designing the application using the NetBeans and the Swing framework. Thank you

Upvotes: 0

Views: 9372

Answers (1)

mKorbel
mKorbel

Reputation: 109815

I am wondering how can I design the GUIs so that EVERY object on the GUI resizes proportionally to fit the screen resolution?

  • not easy job you have to test all possible pixels ratio that exist (by default is possible to change and set various pixels ratio on todays fullHD screen) with lot of fails

  • this is reason why LayoutManagers exist,

  • I'd suggest to use NestedLayout

  • sure there are custom LayoutManagers, for example by using MigLayout (something betweens GridBagLayout and SpringLayout) is possible to put all JComponents to the container from one place, but again I'd be suggest use NestedLayout instead

  • you have to set (internally) minimum screenSize for displaying contents in the JScrollPane, for example screen with resolutions less than 1024 x 600 will have the content scrollable, otherwise let's this job for LayoutManagers,

  • this idea required model JFrame ---> JScrollPane ---> JPanel (father panel) in all cases, JScrollPane will protect your GUI against small (and dual too) screen resolutions

  • you have to look at FontMetrics for Font, because you need in/decrease Font size for various pixel ratios continiously with JComponents size on the screen

  • same with Icons if exist, prepare that before in some of Graphics SW's, not resize on runtime

  • my view ---> any Framework based on AWT/Swing isn't advantage for job this nature,

Upvotes: 4

Related Questions