SearchFactory implements UIDependent { @Override public void updateUI() { if (findBar != null) { SwingUtilities.updateComponentTreeUI(findBar); } if (findPanel != null) { SwingUtilities.updateComponentTreeUI(findPanel); } } SearchFactory(); static SearchFactory getInstance(); static void setInstance(SearchFactory factory); KeyStroke getSearchAccelerator(); boolean isUseFindBar(JComponent target, Searchable searchable); void setUseFindBar(boolean incremental); void showFindInput(JComponent target, Searchable searchable); void showFindBar(JComponent target, Searchable searchable); JXFindBar getSharedFindBar(); JXFindBar createFindBar(); void showFindDialog(JComponent target, Searchable searchable); JXFindPanel getSharedFindPanel(); JXFindPanel createFindPanel(); @Override void updateUI();  }
@Test public void testUpdateUI() throws Exception { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); final boolean[] updated = new boolean[] {false, false}; SearchFactory.setInstance(new SearchFactory() { @Override public JXFindBar createFindBar() { return new JXFindBar() { @Override public void updateUI() { updated[0] = true; super.updateUI(); } }; } @Override public JXFindPanel createFindPanel() { return new JXFindPanel() { @Override public void updateUI() { updated[1] = true; super.updateUI(); } }; } }); JXFindBar bar = SearchFactory.getInstance().getSharedFindBar(); JXFindPanel panel = SearchFactory.getInstance().getSharedFindPanel(); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); assertThat(bar, is(sameInstance(SearchFactory.getInstance().getSharedFindBar()))); assertThat(updated[0], is(true)); assertThat(panel, is(sameInstance(SearchFactory.getInstance().getSharedFindPanel()))); assertThat(updated[1], is(true)); }