void () { applyEditor(getSelectedTemplate()); FileTemplateTab tab = currentTab; final int selectedIndex = myTabbedPane.getSelectedIndex(); if (0 <= selectedIndex && selectedIndex < myTabs.length) { currentTab = myTabs[selectedIndex]; } ((CardLayout)myLeftPanel.getLayout()).show(myLeftPanel, currentTab.getTitle()); onListSelectionChanged(); // request focus to a list (or tree) later to avoid moving focus to the tabbed pane if (tab != currentTab) EventQueue.invokeLater(currentTab.getComponent()::requestFocus); }