how to display JFrame in full screen display mode at a multi-monitor environment?

 ̄綄美尐妖づ 提交于 2019-12-13 12:21:54

问题


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.


回答1:


Try this,

For Single Screen

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

For Multiple Screen

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();
}


来源:https://stackoverflow.com/questions/10928293/how-to-display-jframe-in-full-screen-display-mode-at-a-multi-monitor-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!