Java应用程序自动调整大小以适应屏幕分辨率 [英] Java application automatically resize to fit screen resolution

查看:1289
本文介绍了Java应用程序自动调整大小以适应屏幕分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发的触摸屏应用程序将用于不同的屏幕分辨率。我以前从来没有担心过,但现在我做到了。我想知道如何设计GUI,以便GUI上的每个对象按比例调整大小以适应屏幕分辨率?你能把我推荐给一个好的教程页面吗?我正在使用NetBeans和Swing框架设计应用程序。谢谢

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

推荐答案


我想知道如何设计GUI以便GUI上的每个对象按比例调整大小以适应屏幕分辨率?

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

      这就是为什么存在LayoutManagers

      我建议使用 NestedLayout

      确保有自定义 LayoutManagers ,例如使用 MigLayout (介于 GridBagLayout SpringLayout 之间)可以将所有JComponent放入容器从一个地方,但我再次建议使用 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

      你必须设置(内部)用于在 JScrollPane 中显示内容的最小screenSize,例如分辨率小于1024 x 600的屏幕将使内容可滚动,否则让这个工作为 LayoutManagers

      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,

      这个想法需要模型 JFrame ---> JScrollPane ---> JPanel (父亲面板)在所有情况下, JScrollPane 将保护您的GUI免受小(和双重)屏幕分辨率的影响

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

      您必须查看 FontMetrics for Font ,因为你需要使用/ $ c c> c>大小大小的各种像素比率连续 JComponents 屏幕尺寸

      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

      图标相同如果存在,准备之前在某些Graphics SW中,不在运行时调整大小

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

      我的观点--->基于 AWT / Swing 的任何框架对于这种性质的工作来说不是有利的,

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

      这篇关于Java应用程序自动调整大小以适应屏幕分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆