diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/WidgetPopupHelper.java b/core/src/main/java/com/github/weisj/darklaf/ui/WidgetPopupHelper.java index 1532cf13..75772f80 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/WidgetPopupHelper.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/WidgetPopupHelper.java @@ -29,28 +29,29 @@ import com.github.weisj.darklaf.util.DarkUIUtil; public class WidgetPopupHelper { - public static Rectangle getPopupBounds(final JComponent parent, final JComponent popup, final Dimension popupSize) { - return getPopupBounds(parent, popup, popupSize, true, false); + public static Rectangle getPopupBounds(final JComponent parent, final Dimension popupSize, + final Dimension parentSize) { + return getPopupBounds(parent, popupSize, parentSize, true, false); } - public static Rectangle getPopupBounds(final JComponent parent, final JComponent popup, final Dimension popupSize, + public static Rectangle getPopupBounds(final JComponent parent, final Dimension popupSize, + final Dimension parentSize, final boolean useParentSizeAsMinimum, final boolean alignOpposite) { Insets parentIns = parent.getInsets(); - Insets popupIns = popup.getInsets(); // reduce the width of the popup by the insets so that the popup // is the same width as the parent. if (useParentSizeAsMinimum) { - popupSize.width = Math.max(popupSize.width, parent.getWidth() - parentIns.left - parentIns.right); + popupSize.width = Math.max(popupSize.width, parentSize.width - parentIns.left - parentIns.right); } // popupSize.width -= popupIns.left + popupIns.right; boolean ltr = parent.getComponentOrientation().isLeftToRight(); if (alignOpposite) ltr = !ltr; - int x = ltr ? parentIns.left : parent.getWidth() - parentIns.right - popupSize.width; + int x = ltr ? parentIns.left : parentSize.width - parentIns.right - popupSize.width; - return computePopupBounds(parent, x, parent.getHeight() - parentIns.bottom, popupSize.width, popupSize.height); + return computePopupBounds(parent, x, parentSize.height - parentIns.bottom, popupSize.width, popupSize.height); } protected static Rectangle computePopupBounds(final JComponent parent, final int px, final int py, final int pw, diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboPopup.java b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboPopup.java index 7f8b8f6a..91efa954 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboPopup.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboPopup.java @@ -133,9 +133,17 @@ public class DarkComboPopup extends BasicComboPopup { } protected Point getPopupLocation() { + scroller.setPreferredSize(null); Dimension dim = getPreferredSize(); dim.height = getPopupHeightForRowCount(comboBox.getMaximumRowCount()); - Rectangle popupBounds = WidgetPopupHelper.getPopupBounds(comboBox, this, dim); + + Dimension parentSize = comboBox.getSize(); + Insets ins = getInsets(); + parentSize.width -= ins.left + ins.right; + dim.width -= ins.left + ins.right; + + Rectangle popupBounds = WidgetPopupHelper.getPopupBounds(comboBox, dim, parentSize); + Dimension scrollSize = popupBounds.getSize(); Point popupLocation = popupBounds.getLocation(); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/splitbutton/DarkSplitButtonListener.java b/core/src/main/java/com/github/weisj/darklaf/ui/splitbutton/DarkSplitButtonListener.java index 653cf9e6..58621c23 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/splitbutton/DarkSplitButtonListener.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/splitbutton/DarkSplitButtonListener.java @@ -55,7 +55,8 @@ public class DarkSplitButtonListener implements ActionListener, PropertyChangeLi actionMenu.setPreferredSize(null); Dimension size = actionMenu.getPreferredSize(); Rectangle popupBounds = - WidgetPopupHelper.getPopupBounds(ui.splitButton, actionMenu, size, splitButton, !splitButton); + WidgetPopupHelper.getPopupBounds(ui.splitButton, size, ui.splitButton.getSize(), splitButton, + !splitButton); if (splitButton) { actionMenu.setPreferredSize(popupBounds.getSize()); }