void (ChangeEvent e) { ContentManager contentManager = contentUI.getManager(); if (contentManager != null) { tabbedPane.removeChangeListener(this); ServicesTabbedPaneContentManagerListener listener = new ServicesTabbedPaneContentManagerListener(() -> { TabbedPaneUI ui = tabbedPane.getUI(); return ui instanceof ServiceViewDetailsTabbedPaneUI servicesUI ? servicesUI.getToolbarWrapper() : null; }); Content content = contentManager.getSelectedContent(); if (content != null) { // Process current selection. ContentManagerEvent event = new ContentManagerEvent(contentManager, content, contentManager.getIndexOfContent(content), ContentManagerEvent.ContentOperation.add); listener.selectionChanged(event); } contentManager.addContentManagerListener(listener); } }