Dimension () { if (myDisposed || !myList.isEmpty()) { return super.getPreferredSize(); } else { final NavBarItem item = new NavBarItem(this, null, 0, null); final Dimension size = item.getPreferredSize(); //noinspection deprecation ProjectUtilKt.executeOnPooledThread(myProject, () -> Disposer.dispose(item)); return size; } }