如何在SWT / Java App中禁用Mac OS中的全屏按钮?

我正在研究SWT应用程序。 它在Windows上工作正常,但是当我在mac上运行相同的代码时。 我在shell的右上角有一个全屏按钮。

在此处输入图像描述

单击该全屏按钮时,应用程序停止响应并且没有任何反应。 我想禁用全屏按钮上的点击。

display = Display.getDefault(); shell = new Shell(display, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); setDialogShell(shell); getDialogShell().setLayout( new FormLayout()); getDialogShell().setFullScreen(false); 

请帮忙。 我已经通过这个链接,但没有得到如何禁用mac中的全屏按钮。

 display = Display.getDefault(); shell = new Shell(display, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); //Shell shell = window.getShell(); NSWindow nswindow = shell.view.window(); nswindow.setCollectionBehavior(0); nswindow.setShowsResizeIndicator(false); setDialogShell(shell); getDialogShell().setLayout( new FormLayout()); getDialogShell().setFullScreen(false); 

这对我有用..

**** * 编辑 * * ** * ** * ** * ** * **

上面的代码没有在windows中运行,因为没有公认的“NSWindow”类。 对于使用窗口和mac的公共代码,请使用以下代码。

 public static boolean isWindows() { return (System.getProperty("os.name").toLowerCase().indexOf("win") >= 0); } 

///检查操作系统是否为Window,然后按如下方式更改代码

 display = Display.getDefault(); shell = new Shell(display, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); //Shell shell = window.getShell(); if(!isWindows()){ Field field = Control.class.getDeclaredField("view"); Object /*NSView*/ view = field.get(shell); if (view != null) { Class c = Class.forName("org.eclipse.swt.internal.cocoa.NSView"); Object /*NSWindow*/ window = c.getDeclaredMethod("window").invoke(view); c = Class.forName("org.eclipse.swt.internal.cocoa.NSWindow"); Method setCollectionBehavior = c.getDeclaredMethod( "setCollectionBehavior", /*JVM.is64bit() ?*/ long.class /*: int.class*/); setCollectionBehavior.invoke(window,0); } // NSWindow nswindow = shell.view.window(); // nswindow.setCollectionBehavior(0) ; // nswindow.setShowsResizeIndicator(false); } setDialogShell(shell); getDialogShell().setLayout( new FormLayout()); getDialogShell().setFullScreen(false); getDialogShell().layout(); getDialogShell().pack();