You can use the same concept SwingUtilities updateComponentTreeUI function is using.
This is the code for updateComponentTreeUI function.
This is a recursive function that iterates over a component and its descendants and calls updateUI for each JComponent.
Just modify the code to setEnabled instead of updateUI.
private static void updateComponentTreeUI0(Component c) {
if (c instanceof JComponent) {
((JComponent) c).updateUI();
}
Component[] children = null;
if (c instanceof JMenu) {
children = ((JMenu)c).getMenuComponents();
}
else if (c instanceof Container) {
children = ((Container)c).getComponents();
}
if (children != null) {
for(int i = 0; i < children.length; i++) {
updateComponentTreeUI0(children[i]);
}
}
}