ContentUI () { TabbedPaneContentUI contentUI = new TabbedPaneContentUI(SwingConstants.TOP); JComponent component = contentUI.getComponent(); if (component instanceof TabbedPaneWrapper.TabbedPaneHolder holder) { JComponent holderComponent = holder.getTabbedPaneWrapper().getTabbedPane().getComponent(); if (holderComponent instanceof JTabbedPane tabbedPane) { tabbedPane.setUI(new ServiceViewDetailsTabbedPaneUI()); tabbedPane.addPropertyChangeListener("UI", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (!(evt.getNewValue() instanceof ServiceViewDetailsTabbedPaneUI)) { tabbedPane.setUI(new ServiceViewDetailsTabbedPaneUI()); } } }); if (ServiceViewUIUtils.isNewServicesUIEnabled()) { tabbedPane.addChangeListener(new ChangeListener() { @Override public void stateChanged(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); } } }); } } } return contentUI; }