Java的:获取一个/所有可用的监视器(而不是整个桌面)的决议? [英] Java: Getting resolutions of one/all available monitors (instead of the whole desktop)?

查看:115
本文介绍了Java的:获取一个/所有可用的监视器(而不是整个桌面)的决议?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个不同大小的显示器,使用(我相信)特威维尤。

I have two different-sized monitors, connected together using (I believe) TwinView.

我试过

System.out.println(Toolkit.getDefaultToolkit().getScreenSize());

和取得

java.awt.Dimension[width=2960,height=1050]

如果算上两个监视器这是真的在一起

而不是这一点,我想能够在下面的实现有一个

Instead of this, I would like to be able achieving one of the following:


  • 当前显示器的分辨率越来越

  • 主监视器的分辨率越来越

推荐答案

你要使用的 GraphicsEnvironment中

在具体地,getScreenDevices()返回的阵列GraphicsDevice的的,从中可以读出显示模式的宽度/高度的对象。

In particular, getScreenDevices() returns an array of GraphicsDevice objects from which you can read the width/height of the display mode.

例如:

GraphicsEnvironment g = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] devices = g.getScreenDevices();

for (int i = 0; i < devices.length; i++) {
    System.out.println("Width:" + devices[i].getDisplayMode().getWidth());
    System.out.println("Height:" + devices[i].getDisplayMode().getHeight());
} 

这篇关于Java的:获取一个/所有可用的监视器(而不是整个桌面)的决议?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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