JComponent (@NotNull ToolWindow toolWindow) { Content selectedContent = toolWindow.getContentManager().getSelectedContent(); if (selectedContent != null) { return selectedContent.getPreferredFocusableComponent(); } else { return toolWindow.getComponent(); } }