if (!root.isVisible () || !root.isDisplayable ()) return null;  if (accept (root)) return root;  Component[] componentArray = root.getComponents ();  for (int i = 0; i < componentArray.length; i++) { Component component = componentArray [i];  if (component instanceof Container) { Component result = getLastComponent ((Container) component);  if (result != null) return result; } else { if (accept (component)) return component; } }
  public Component getFirstComponent(Container root)  {    if (root == null)      throw new IllegalArgumentException ();    return null;  }