I wrote a java program and I let the user use the Mac fullscreen feature, and I want to be able to know if the program is fullscreen or not. The problem is that I don't know how to detect when the user makes the program fullscreen, because they do so by clicking a button that isn't part of my program. Is there any way to detect if my program is fullscreen?
If I wasn't clear enough, here is an example of the fullscreen button.
Have your JFrame (I'm assuming that you're using one) implement com.apple.eawt.FullScreenListener
. You will then have access to the following methods:
@Override
public void windowEnteringFullScreen(AppEvent.FullScreenEvent fse) {
}
@Override
public void windowEnteredFullScreen(AppEvent.FullScreenEvent fse) {
}
@Override
public void windowExitingFullScreen(AppEvent.FullScreenEvent fse) {
}
@Override
public void windowExitedFullScreen(AppEvent.FullScreenEvent fse) {
}
And you can then do something similar to what tincopper2 said; set a boolean to true/false depending on if the window is opening or closing.
Source: the comments on the correct answer to this question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With