void (@Nullable Runnable onDone, boolean shouldBeCentered) { SwingUtilities.invokeLater(new TreeRunnable("AbstractTreeUi.scrollSelectionToVisible") { @Override public void perform() { if (isReleased()) return; int[] rows = myTree.getSelectionRows(); if (rows == null || rows.length == 0) { runDone(onDone); return; } Object toSelect = null; for (int eachRow : rows) { TreePath path = myTree.getPathForRow(eachRow); toSelect = getElementFor(path.getLastPathComponent()); if (toSelect != null) break; } if (toSelect != null) { selectVisible(toSelect, onDone, true, shouldBeCentered, true); } } }); }