Java / Swing如何处理不同的屏幕DPI和密度设置? [英] Java / Swing how to deal with different screen DPI and density settings?

查看:364
本文介绍了Java / Swing如何处理不同的屏幕DPI和密度设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我最近遇到了一个问题:如今,有些显示器具有不同的DPI设置,有些显示器密度更高,例如Apple的Retina显示器。

Hi everyone I've recently come across the problem that now days some monitors have different DPI settings, some monitors are much more dense such as, for example, Apple's Retina displays.

如何用Java补偿各种显示器上不同的DPI设置和密度?是否可以在任何监视器上将控件缩放为相同大小。我知道在为Android进行编程时,所有测量值均位于 DP中,您可以为三种不同的显示密度指定不同的图像。

How would one compensate for the different DPI settings and densities on various monitors with Java? Is it possible to scale the controls to be the same size on any monitor. I know when programming for Android all measurements are in "DP" and you can specify different images for three different display densities.

是否可以使用Java / Swing为不同的显示密度选择不同的图像,以使我的应用程序在高密度显示器上看起来不会模糊?还是这不那么重要或不可能?我知道Chrome当前不考虑DPI,但Internet Explorer和其他应用程序考虑了DPI。

Is there a way I could choose different images using Java / Swing for different display densities so my application doesn't look blurry on higher density monitors? Or is this not that important or possible? I know Chrome currently doesn't take into account DPI but Internet Explorer and other apps do.

感谢您的帮助,我是Java开发人员很久了,我ve以前从未考虑过DPI,并且想知道我会怎么做:)

Thank you for your help, I'm a long time Java developer I've just never thought about DPI before and was wondering how I might go about it :)

推荐答案

首先,请信任平台的Look& ;设计师可以选择合理的文本和控件默认大小。然后,避免使这些默认值受挫的诱惑。以下是一些启发式方法:

First, trust the platform's Look & Feel designers to choose sensible default sizes for text and controls. Then, avoid the temptation to frustrate those defaults. Here are some heuristics:


  • 使用布局;在考虑绝对定位时,请考虑自定义布局。

  • Use layouts; when contemplating absolute positioning, consider a custom layout.

尊重组件的首选大小

避免非可调整大小的组件

动画,将图形缩放到封闭的 Window 的大小。

In animation, scale graphics to the size of the enclosing Window.

在各种平台上进行测试,

Test across a range of platforms, using emulation as required.

这篇关于Java / Swing如何处理不同的屏幕DPI和密度设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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