Popup.hide() doing absolutely nothing

I have a swing Popup. I am creating it like this:
JPanel panel = new JPanel(new GridLayout(0, 1));
Point screenPoint = getLocationOnScreen();
popup = PopupFactory.getSharedInstance().getPopup(this, panel, screenPoint.x, screenPoint.y + getHeight());

As you can see, it looks good (I am doing this inside a custom dropdown JComponent). Then, I add buttons to it:
for (E item : items) {
    panel.add(new UButton(item.toString(), 0, 0, 200, 40, UAlignment.Default, e -> {
        open = !open;
        selectedItem = item;
        popup.hide();
        repaint();
    }) {
        @Override
        int getTexIndex() {
            return selectedItem == item ? 2 : super.getTexIndex();
        }
    });
}

(getTexIndex() is for what texture the button should use, doesn't matter here)
The consumer of MouseEvent is run when the button is released. It should hide the popup, but it doesn't. Then, I show the popup after adding the stuff:
popup.show();

I have absolutely no idea why this code isn't working as intended. Also, it isn't just in this area. Calling hide() somewhere else doesn't work. But, calling hide right after showing it works just fine?
Was this page helpful?