Saturday, 15 May 2010

osx - How to disable fullscreen button in Mac OS in SWT / Java App? -



osx - How to disable fullscreen button in Mac OS in SWT / Java App? -

i working on swt app. works fine on windows, when run same code on mac. total screen button on right corner of shell.

on clicking total screen button app stop responding , nil happens. want disable click on fullscreen button.

display = display.getdefault(); shell = new shell(display, swt.dialog_trim | swt.application_modal); setdialogshell(shell); getdialogshell().setlayout( new formlayout()); getdialogshell().setfullscreen(false);

please help. have gone through link didn't got how disable total screen button in 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);

this worked me..

**** *edit* ***************

the above code not running in windows, no recognised "nswindow" class. using mutual code both window , mac utilize below code.

public static boolean iswindows() { homecoming (system.getproperty("os.name").tolowercase().indexof("win") >= 0); }

/// check if os window, alter code follow

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();

java osx swt fullscreen

No comments:

Post a Comment