Java examples for java.awt:Component
get Components from Container
//package com.java2s; import java.awt.*; import java.util.*; public class Main { public static java.util.List<Component> getComponents( Container container, String classString) { java.util.List<Component> list = new ArrayList<>(); for (Component component : getAllComponents(container)) { if (component.getClass().toString().endsWith(classString)) { list.add(component);/*from w w w . java 2 s . c o m*/ } } return list; } public static java.util.List<Component> getAllComponents( final Container container) { Component[] comps = container.getComponents(); java.util.List<Component> compList = new ArrayList<>(); for (Component comp : comps) { compList.add(comp); if (comp instanceof Container) { compList.addAll(getAllComponents((Container) comp)); } } return compList; } }