Screen display size

前端 未结 7 991
长情又很酷
长情又很酷 2021-01-19 03:50

Hi I\'m writing a graphics program and I\'ve been searching for a way to get the physical size of the screen being used. I can get the size of the screen in pixels and also

7条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-19 04:10

    I don't think it's possible with java. You can try to write some jni code if this feature is absolutely essential in your program. Otherwise, just ask the user for their monitor size.

    EDIT Looks like SWT can give you DPI, and you can calculate the monitor size with it: http://www.java2s.com/Code/JavaAPI/org.eclipse.swt.graphics/DevicegetDPI.htm

    But, you'd have to use SWT :) Which is actually not that bad choice if you want to develop good-looking programs for Mac.

提交回复
热议问题