Component (boolean first) { if (myContentProvider != null) { Content[] contents = myContentProvider.getContents(); if (contents != null && contents.length > 0) { Component preferred = contents[first ? 0 : contents.length - 1].getPreferredFocusableComponent(); if (preferred != null && preferred.isShowing() && accept(preferred)) { return preferred; } } } return null; }