diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuBarBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuBarBorder.java index 05ae59dd..56abcd91 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuBarBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/menu/DarkMenuBarBorder.java @@ -27,8 +27,10 @@ import javax.swing.border.Border; import javax.swing.plaf.InsetsUIResource; import javax.swing.plaf.UIResource; +import com.github.weisj.darklaf.platform.CustomTitlePane; + /** @author Jannis Weis */ -public class DarkMenuBarBorder implements Border, UIResource { +public class DarkMenuBarBorder implements Border, UIResource, CustomTitlePane.BorderCollapseHint { protected final Color borderColor; @@ -51,4 +53,9 @@ public class DarkMenuBarBorder implements Border, UIResource { public boolean isBorderOpaque() { return true; } + + @Override + public int getBottomCollapse() { + return 1; + } } diff --git a/platform-base/src/main/java/com/github/weisj/darklaf/platform/CustomTitlePane.java b/platform-base/src/main/java/com/github/weisj/darklaf/platform/CustomTitlePane.java index 9df47558..50d18aa0 100644 --- a/platform-base/src/main/java/com/github/weisj/darklaf/platform/CustomTitlePane.java +++ b/platform-base/src/main/java/com/github/weisj/darklaf/platform/CustomTitlePane.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2019-2022 Jannis Weis + * Copyright (c) 2019-2023 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, @@ -24,6 +24,10 @@ import javax.swing.*; public abstract class CustomTitlePane extends JComponent { + public interface BorderCollapseHint { + int getBottomCollapse(); + } + protected int decorationStyle; public abstract void uninstall(final boolean removeDecorations); diff --git a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java index c84f9938..f3024b79 100644 --- a/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java +++ b/windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2019-2022 Jannis Weis + * Copyright (c) 2019-2023 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, @@ -865,7 +865,7 @@ public class WindowsTitlePane extends CustomTitlePane { int w = getWidth(); int x; int start = 0; - int y = 0; + final int y = 0; height = computeHeight(); left = 0; right = 0; @@ -881,8 +881,13 @@ public class WindowsTitlePane extends CustomTitlePane { if (menuBarStealer.hasMenuBar()) { int menuWidth = getPreferredMenuSize().width; - Insets menuInsets = menuBarStealer.getMenuBar().getInsets(); - menuBarStealer.getMenuBar().setBounds(start, y, menuWidth, height + menuInsets.bottom); + JMenuBar menuBar = menuBarStealer.getMenuBar(); + Border b = menuBar.getBorder(); + int menuHeight = height; + if (b instanceof BorderCollapseHint) { + menuHeight += ((BorderCollapseHint) b).getBottomCollapse(); + } + menuBarStealer.getMenuBar().setBounds(start, y, menuWidth, menuHeight); start += menuWidth + PAD; left += menuWidth; }