问题
I am trying to get the Java Fullscreen Exclusive Mode to run at 1080p on my computer, but it only has a size of 1536 x 864. The display mode is also set at 1920 x 1080.
GraphicsDevice device = GraphicsEnvironment
.getLocalGraphicsEnvironment().getDefaultScreenDevice();
// device.getDisplayMode() returns 1920 x 1080 and some other stats
// device.getDefaultConfiguration().getBounds() returns 1536 x 864
I'm hoping to try to get the screen to be at 1920 x 1080 rather than 1536 x 864. Is there an actual way to do this or is this normal?
Thanks in advance!
Edit: For now, I'm getting this to work on Windows
回答1:
"Why" that mode is chosen, I can't say, but the first thing you will want to do is check the available modes...
DisplayMode modes[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayModes();
for (DisplayMode mode : modes) {
System.out.println(mode);
}
So, on my 2017 MacBook Pro, running macOS Maojave (10.14) I get...
2880x1800x32bpp@[Unknown refresh rate]
1440x900x32bpp@[Unknown refresh rate]
3360x2100x32bpp@[Unknown refresh rate]
2560x1600x32bpp@[Unknown refresh rate]
2048x1280x32bpp@[Unknown refresh rate]
1650x1050x32bpp@[Unknown refresh rate]
1280x800x32bpp@[Unknown refresh rate]
1152x720x32bpp@[Unknown refresh rate]
1024x768x32bpp@[Unknown refresh rate]
840x524x32bpp@[Unknown refresh rate]
800x600x32bpp@[Unknown refresh rate]
640x480x32bpp@[Unknown refresh rate]
1680x1050x32bpp@[Unknown refresh rate]
But, as you can see, 1080p isn't supported here :(, so if I was in your shoes, I'd need to find something which was close. Maybe, 1650x1050 or 2048x1280
How does that help you? Well, once you've determined the best mode for your needs, and according to the documentation, you can simply do...
GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
device.setFullScreenWindow(frame);
device.setDisplayMode(mode);
来源:https://stackoverflow.com/questions/55778586/why-isnt-java-fullscreen-exclusive-mode-running-my-max-screen-resolution