如何在多显示器环境下以全屏显示模式显示JFrame? [英] how to display JFrame in full screen display mode at a multi-monitor environment?

查看:97
本文介绍了如何在多显示器环境下以全屏显示模式显示JFrame?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个JFrame,当它在多监视器环境中时,如何以全屏显示方式显示此JFrame?例如,现在JFrame显示在监视器1中,当要更改为全屏显示模式时,它必须显示在监视器1中;否则,它必须显示在监视器1中.如果在监视器2中显示,当要更改为全屏显示模式时,必须以 监视器2.

There is a JFrame, when it in a multi-monitor environment, how to display this JFrame in full screen display? For example, now the JFrame is displaying in monitor 1, when it is going to change to full screen display mode,it must be displayed in the monitor 1; if is displaying in monitor 2,when it is going to change to full screen display mode, it must be displayed in the monitor 2.

推荐答案

尝试一下,

单屏显示

Toolkit tool = Toolkit.getDefaultToolkit();
Dimension dim = tool.getScreenSize();
int screenWidth = dim.getWidth();
int screenHeight = dim.getHeight();

用于多屏

GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();


// Get size of each screen

for (int i=0; i<gs.length; i++) {
    DisplayMode dm = gs[i].getDisplayMode();
    int screenWidth = dm.getWidth();
    int screenHeight = dm.getHeight();
}

这篇关于如何在多显示器环境下以全屏显示模式显示JFrame?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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