public static void enableElements(Container container, boolean shouldBeEnabled) {
        Component[] components = container.getComponents();
        for (Component c : components) {
            c.setEnabled(shouldBeEnabled);
            if (c instanceof Container) {
                enableElements((Container) c, shouldBeEnabled);
            }
        }
    }