如何获得Java中每个单独屏幕的尺寸
我需要一个使我个人监视器的分辨率的功能。
我确实知道 toolkit.getDefaultToolKit()。getScreensize()
为我提供了所有监视器的累积分辨率,但是为了限制我绘制的某些框架的大小,我想知道单个屏幕的分辨率。
我尝试使用 graphicSenvironment.getLocalGraphicsEnvironment()。getScreendevices()
,它返回了所有屏幕的数组,但是我找不到其中的任何分辨率信息。
功能的标题应该是
/**
* Returns the Dimension of all available screen devices in order of appearance in
* GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()
*
* @return the Dimensions of all available screen devices.
*/
public Dimension[] getScreenResolutions() {
[ . . . ]
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使用。该文档显示了如何获得屏幕界限。
You need to use GraphicsConfiguration. The documentation shows how to get the screen bounds.
当Rob Spoor回答时,我刚刚发现了同样的内容,所以我要对我的问题给出一个完整的答案:
GraphicsDevice
具有函数getDefaultConfiguration()
返回a <代码> GraphicsConfiguration 具有getBounds()
方法,该方法再次将值返回为矩形
。因此,我的功能标题的实现将是:
I just found out the same, while Rob Spoor answered, so I'm gonna give a full answer to my question:
GraphicsDevice
has a functiongetDefaultConfiguration()
which returns aGraphicsConfiguration
which has agetBounds()
method which again returns the values as aRectangle
.An implementation of my function header would therefore be: