ItemWrapper[] () { Object[] values = ArrayUtilRt.EMPTY_OBJECT_ARRAY; if (myChooserComponent instanceof JList) { //noinspection deprecation values = ((JList<?>)myChooserComponent).getSelectedValues(); } else if (myChooserComponent instanceof JTree) { values = myDelegate.getSelectedItemsInTree(); } ItemWrapper[] items = new ItemWrapper[values.length]; for (int i = 0; i < values.length; i++) { items[i] = (ItemWrapper)values[i]; } return items; }