< prev index next >

src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java

Print this page




  88         pingFrame.setVisible(true);
  89         pingFrame.toFront();
  90         pingFrame.setVisible(false);
  91         pingFrame.dispose();
  92     }
  93 
  94     static boolean isFrameMinimized(final Frame frame) {
  95         return (frame.getExtendedState() & Frame.ICONIFIED) != 0;
  96     }
  97 
  98     static void installDefaultMenuBar(final JMenuBar menuBar) {
  99         if (menuBar == null) {
 100             // intentionally clearing the default menu
 101             nativeSetDefaultMenuBar(0);
 102             return;
 103         }
 104 
 105         final MenuBarUI ui = menuBar.getUI();
 106         if (!(ui instanceof AquaMenuBarUI)) {
 107             // Aqua was not installed
 108             throw new IllegalStateException("Application.setDefaultMenuBar() only works with the Aqua Look and Feel");
 109         }
 110 
 111         final AquaMenuBarUI aquaUI = (AquaMenuBarUI)ui;
 112         final ScreenMenuBar screenMenuBar = aquaUI.getScreenMenuBar();
 113         if (screenMenuBar == null) {
 114             // Aqua is installed, but we aren't using the screen menu bar
 115             throw new IllegalStateException("Application.setDefaultMenuBar() only works if apple.laf.useScreenMenuBar=true");
 116         }
 117 
 118         screenMenuBar.addNotify();
 119         final Object peer = AWTAccessor.getMenuComponentAccessor().getPeer(screenMenuBar);
 120         if (!(peer instanceof CMenuBar)) {
 121             // such a thing should not be possible
 122             throw new IllegalStateException("Unable to determine native menu bar from provided JMenuBar");
 123         }
 124 
 125         // grab the pointer to the CMenuBar, and retain it in native
 126         ((CMenuBar) peer).execute(_AppMenuBarHandler::nativeSetDefaultMenuBar);
 127     }
 128 
 129     void setAboutMenuItemVisible(final boolean present) {
 130         synchronized (this) {
 131             if (aboutMenuItemVisible == present) return;
 132             aboutMenuItemVisible = present;
 133         }
 134 
 135         nativeSetMenuState(MENU_ABOUT, aboutMenuItemVisible, aboutMenuItemEnabled);




  88         pingFrame.setVisible(true);
  89         pingFrame.toFront();
  90         pingFrame.setVisible(false);
  91         pingFrame.dispose();
  92     }
  93 
  94     static boolean isFrameMinimized(final Frame frame) {
  95         return (frame.getExtendedState() & Frame.ICONIFIED) != 0;
  96     }
  97 
  98     static void installDefaultMenuBar(final JMenuBar menuBar) {
  99         if (menuBar == null) {
 100             // intentionally clearing the default menu
 101             nativeSetDefaultMenuBar(0);
 102             return;
 103         }
 104 
 105         final MenuBarUI ui = menuBar.getUI();
 106         if (!(ui instanceof AquaMenuBarUI)) {
 107             // Aqua was not installed
 108             return;
 109         }
 110 
 111         final AquaMenuBarUI aquaUI = (AquaMenuBarUI)ui;
 112         final ScreenMenuBar screenMenuBar = aquaUI.getScreenMenuBar();
 113         if (screenMenuBar == null) {
 114             // Aqua is installed, but we aren't using the screen menu bar
 115             return;
 116         }
 117 
 118         screenMenuBar.addNotify();
 119         final Object peer = AWTAccessor.getMenuComponentAccessor().getPeer(screenMenuBar);
 120         if (!(peer instanceof CMenuBar)) {
 121             // such a thing should not be possible
 122             throw new IllegalStateException("Unable to determine native menu bar from provided JMenuBar");
 123         }
 124 
 125         // grab the pointer to the CMenuBar, and retain it in native
 126         ((CMenuBar) peer).execute(_AppMenuBarHandler::nativeSetDefaultMenuBar);
 127     }
 128 
 129     void setAboutMenuItemVisible(final boolean present) {
 130         synchronized (this) {
 131             if (aboutMenuItemVisible == present) return;
 132             aboutMenuItemVisible = present;
 133         }
 134 
 135         nativeSetMenuState(MENU_ABOUT, aboutMenuItemVisible, aboutMenuItemEnabled);


< prev index next >