Java Toolkit Getting Second screen size

前端 未结 4 1662
粉色の甜心
粉色の甜心 2020-11-29 10:24

I have two screens plugged into my computer and was wondering if there was a way in JFrame or Toolkit of detecting which screen the window is on?

I have this code:

4条回答
  •  被撕碎了的回忆
    2020-11-29 11:11

    If you use the code shown here you can iterate over all the GraphicsDevices in the system and get their dimensions. Given that you can create a JFrame on a specific GraphicsDevice you can also fetch the specific GraphicsDevice a JFrame is on by getting the JFrame's Window, calling http://download.oracle.com/javase/6/docs/api/java/awt/Window.html#getGraphicsConfiguration() on the Window and then calling getGraphicsDevice on that.

提交回复
热议问题