1

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

poroia
  • 45
  • 1
  • 10
  • 1
    Let's not forget that on MacOS, "full screen mode" has a different user expectation then on different OSes, [for example](https://stackoverflow.com/questions/30089804/true-full-screen-jframe-swing-application-in-mac-osx/30090377#30090377) – MadProgrammer Apr 20 '19 at 23:27
  • @MadProgrammer Thanks, I'll keep that in mind. – poroia Apr 20 '19 at 23:40
  • Well, it would seem that the eawt packages are no longer available and there isn't any replacement for full screen support in the base API, meaning you'd have to use a JNI/JNA approach to achieve it, which is a shame, because it worked really well :( – MadProgrammer Apr 20 '19 at 23:47
  • Hm, correct me if I'm wrong, but are you saying that the native full screen support no longer can achieve this and that I'll have to use those libraries to implement this? – poroia Apr 20 '19 at 23:51
  • That's correct. Apple no longer supplies the `eawt` package or libraries, and while some of the functionality has been rolled over to the `Desktop` API, native full screen support (like you would get from pressing the green expand button on the window) is not support from a code stand point. – MadProgrammer Apr 20 '19 at 23:53
  • Ah, but this issue only pertains to MacOS's support for full screen capabilities, right? – poroia Apr 20 '19 at 23:57
  • Yes, MacOS's "native" full screen support, which works, "slightly" differently to Java's "exclusive mode", way to confuse the users ;) – MadProgrammer Apr 21 '19 at 00:00
  • :( Ah. Thanks for the notice! – poroia Apr 21 '19 at 00:03

2 Answers2

2

"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);
MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
  • Thanks so much for your response! I still don't know what's up. I'm using a computer with 128 display modes which does include 1080p, and the current display mode is set to 1080p (as seen through the "// device.getDisplayMode() returns 1920 x 1080 and some other stats." However, when I actually check the full screen dimensions, it turns out to be 1536 x 864 (which actually isn't an available display mode). Furthermore, to double check, when I draw to the screen, I can only see objects within 1536 x 864. (It also happens to be that 1536 is 80% of 1920...). Hope I clarified a bit. – poroia Apr 20 '19 at 23:49
  • In most cases, either Java or MacOS is making a decision about the best mode to use based on a bunch of internal decisions, which I don't know. The best choice is to simply find the mode you want and set it directly. It "could" be a driver issue, but without a runnable example that replicates the issue, I can't say for sure – MadProgrammer Apr 20 '19 at 23:51
  • I would also like to note that even in windowed mode, the screen appears to be limited to 1536 x 864. This may just be an entirely different issue that doesn't relate to display modes. – poroia Apr 20 '19 at 23:53
  • It was just a thought. My computer's current resolution is 1920 x 1080, so I really don't know what's up. Thanks so much for your help! – poroia Apr 21 '19 at 00:05
  • Well, based on what you're telling us, it would "seem" that the screen is in fact using 1920x1080, but you have something restricting the size of the output area you're using – MadProgrammer Apr 21 '19 at 00:34
  • Hey! I figured it out: when I reverted my workspace's JRE back to 1.8 instead of v11, the screen dimensions went from 1536 x 864 to 1920 x 1080, meaning it works! Both the above statements are now 1920 x 1080. I'm not sure entirely why... just that there may be something else going on that's restricting it (just like you said), but in this case, it's the newer Java version. Thank you for your time and I'm glad we figured it out! – poroia Apr 22 '19 at 15:50
  • In terms of providing an "answer" to this question, how would that work? It doesn't feel right if I create a new answer and just accept it, completely disregarding your insight lol. – poroia Apr 22 '19 at 15:53
  • Unfortunately, when I exported the project into a runnable .jar file, I got the same issue again. It works in the Eclipse workspace environment but not when I run it from the .jar file. I can try another editor and see if the issue continues. – poroia Apr 22 '19 at 15:58
  • I created a new question surrounding this new issue. https://stackoverflow.com/questions/55799150/executable-jar-has-a-smaller-canvas-than-using-the-eclipse-runner. Do you have any ideas? Thanks :) – poroia Apr 22 '19 at 18:40
0

It's been a little bit of time and I realized that I didn't answer the question. I eventually figured it out and the issue was likely a bug in Java 11. When I reverted back to the Java 8 development environment (v221?), the pixels went back to 1920 x 1080.

poroia
  • 45
  • 1
  • 10
  • I just realized that I answered it in a comment in the below answer. See the comments below for details. – poroia Feb 14 '20 at 23:26