Mac OSX上的Java - 检测程序是否已完全筛选

Tyl*_*ler 5 java macos fullscreen

我写了一个java程序,让用户使用Mac全屏功能,我希望能够知道程序是否全屏.问题是我不知道如何检测用户何时使程序全屏,因为他们通过单击不属于我程序的按钮来执行此操作.有没有办法检测我的程序是否全屏?

如果我不够清楚,这是一个全屏按钮的例子.

全屏按钮示例

Bit*_*nja 3

让您的 JFrame(我假设您正在使用一个)实现com.apple.eawt.FullScreenListener. 然后您将可以使用以下方法:

@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) {
}
Run Code Online (Sandbox Code Playgroud)

然后你可以做类似于tincopper2所说的事情;根据窗口是打开还是关闭,将布尔值设置为 true/false。

来源:对该问题正确答案的评论。