void (final Container comboComponent) { if (comboComponent instanceof JButton) { ((JButton)comboComponent).doClick(); } else { for (int i = 0; i < comboComponent.getComponentCount(); i++) { Component child = comboComponent.getComponent(i); if (child instanceof Container) { press((Container)child); } } } }