public void eventDispatched(AWTEvent event) {
            if (MouseEvent.MOUSE_CLICKED == event.getID() && event.getSource() != button) {
                Set<Component> components = getAllComponents(datePanel);
                boolean clickInPopup = false;
                for (Component component : components) {
                    if (event.getSource() == component) {
                        clickInPopup = true;
                    }
                }
                if (!clickInPopup) {
                    hidePopup();
                }
            }
        }