diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuUI.java index 391e3394..8a588d5b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/DarkPopupMenuUI.java @@ -56,6 +56,10 @@ public class DarkPopupMenuUI extends BasicPopupMenuUI { return new DarkPopupMenuUI(); } + public DarkPopupMenuUI() { + EventHelperUtil.installEventHelper(); + } + @Override public void paint(final Graphics g, final JComponent c) { Window window = SwingUtilities.getWindowAncestor(c); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/EventHelperUtil.java b/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/EventHelperUtil.java new file mode 100644 index 00000000..9638bd75 --- /dev/null +++ b/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/EventHelperUtil.java @@ -0,0 +1,66 @@ +/* + * MIT License + * + * Copyright (c) 2020 Jannis Weis + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ +package com.github.weisj.darklaf.ui.popupmenu; + +import javax.swing.plaf.basic.BasicLookAndFeel; + +public class EventHelperUtil { + + private static boolean eventHelperInstallerFlagSet; + + public static void installEventHelper() { + if (eventHelperInstallerFlagSet) return; + eventHelperInstallerFlagSet = true; + new DummyBasicLookAndFeel().initialize(); + } + + private static class DummyBasicLookAndFeel extends BasicLookAndFeel { + + @Override + public String getName() { + return null; + } + + @Override + public String getID() { + return null; + } + + @Override + public String getDescription() { + return null; + } + + @Override + public boolean isNativeLookAndFeel() { + return false; + } + + @Override + public boolean isSupportedLookAndFeel() { + return false; + } + } +} diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/MouseGrabberUtil.java b/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/MouseGrabberUtil.java index 0cc0e9d1..ffe05f96 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/MouseGrabberUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/MouseGrabberUtil.java @@ -37,9 +37,7 @@ import com.github.weisj.darklaf.util.DarkUIUtil; public class MouseGrabberUtil { - private MouseGrabberUtil() { - - } + private MouseGrabberUtil() {} private static MouseGrabber mouseGrabber; @@ -58,7 +56,7 @@ public class MouseGrabberUtil { } } - public static ChangeListener getOldMouseGrabber() { + private static ChangeListener getOldMouseGrabber() { MenuSelectionManager menuSelectionManager = MenuSelectionManager.defaultManager(); for (ChangeListener listener : menuSelectionManager.getChangeListeners()) { if (listener == null) continue; @@ -78,7 +76,7 @@ public class MouseGrabberUtil { * This Method is responsible for removing the old MouseGrabber from the AppContext, to be able to add our own * implementation for it that is a bit more generous with closing the popup. */ - public static void uninstallOldMouseGrabber(final ChangeListener oldMouseGrabber) { + private static void uninstallOldMouseGrabber(final ChangeListener oldMouseGrabber) { if (oldMouseGrabber == null) return; MenuSelectionManager menuSelectionManager = MenuSelectionManager.defaultManager(); menuSelectionManager.removeChangeListener(oldMouseGrabber);