Oh great, thanks for the info and code. I'll try it out during the weekend.
I understand why one would like to hide the menu item and shortcut when on
mac, but hiding the action looks like overkill to me, unless it was really
necessary that is.

/Patrik

Den tors 7 juni 2018 kl 07:42 skrev Emilian Bold <emilian.b...@protonmail.ch
>:

> What I see in ./applemenu/src/org/netbeans/modules/applemenu/layer.xml
> is that the generic action is hidden on macOS:
>
>  <!-- Hide menu items that belong on Apple's app menu -->
>    <folder name="Actions">
>         <folder name="Window">
>             <file
> name="org-netbeans-core-windows-actions-ToggleFullScreenAction.instance_hidden"/>
>         </folder>
>     </folder>
>
>
> That's why you are getting a null.
>
> So, there is no API to call that action on macOS as far as I can tell.
>
> This workaround does the trick (inspired by
> https://gist.github.com/dohpaz42/4200907 ):
>
>
>     @SuppressWarnings({"unchecked", "rawtypes"})
>     public static void requestToggleFullScreen(Window window)
>     {
>         try {
>             Class appClass = Class.forName("com.apple.eawt.Application");
>             Class params[] = new Class[]{};
>
>             Method getApplication = appClass.getMethod("getApplication",
> params);
>             Object application = getApplication.invoke(appClass);
>             Method requestToggleFulLScreen =
> application.getClass().getMethod("requestToggleFullScreen", Window.class);
>
>             requestToggleFulLScreen.invoke(application, window);
>         } catch (Exception e) {
>             System.out.println("An exception occurred while trying to
> toggle full screen mode");
>         }
>     }
>
> requestToggleFullScreen(Frame.getWindows()[0]);
>
> --emi
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>
> On 6 June 2018 5:44 PM, Patrik Karlström <pat...@trixon.se> wrote:
>
> > Den ons 6 juni 2018 kl 14:36 skrev Emilian Bold <
> emilian.b...@protonmail.ch>:
> >
> > > The actual NPE might help. Maybe you have to create a dummy even and
> not send null to actionPerformed?
> > >
> > > If it's reproducible you should report it to the bugtracker
> https://issues.apache.org/jira/projects/NETBEANS/summary
> > >
> > > --emi
> > >
> > > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> > >
> > > On 6 June 2018 2:36 PM, Patrik Karlström <pat...@trixon.se> wrote:
> > >
> > > > Hi,
> > >
> > > >
> > >
> > > > Actions.forID("Window",
> "org.netbeans.core.windows.actions.ToggleFullScreenAction").actionPerformed(null);
> > >
> > > >
> > >
> > > > I *think* that I have successfully run the code above on a mac a
> couple of years back, but that might have been before they changed their
> maximize/full screen handling.
> > >
> > > >
> > >
> > > > Today I noticed that it failed with an NPE on the mac.
> >
> > Just noticed that it is the action itself that is null.
> >
> > Action a=Actions.forID("Window",
> "org.netbeans.core.windows.actions.ToggleFullScreenAction");
> >
> > results in a==null.
> >
> > All this is done on JDK8 171 and NetBeans 8.2, and on what I guess is an
> up to date Mac.
> >
> > How does it work on other Macs?
>

Reply via email to