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

查看:33
本文介绍了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 存在的原因,

      this is reason why LayoutManagers exist,

      我建议使用 NestedLayout

      确保有自定义的 LayoutManagers,例如通过使用 MigLayout(介于 GridBagLayoutSpringLayout 之间的东西>) 可以将所有 JComponents 从一个地方放到容器中,但我再次建议使用 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 中显示内容,例如分辨率小于 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

      您必须查看 FontMetricsFont,因为您需要针对各种像素比率不断增加/减少 Font 大小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

      Icons 相同,如果存在,请在某些图形软件之前准备好,不要在运行时调整大小

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

      我的观点 ---> 任何基于 AWT/SwingFramework 都不是这种性质的工作的优势,

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

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

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