LookAndFeelAddons { public static void contribute(ComponentAddon component) { contributedComponents.add(component); if (currentAddon != null) { component.initialize(currentAddon); } }  void initialize(); void uninitialize(); void loadDefaults(Object[] keysAndValues); void unloadDefaults(@SuppressWarnings("unused") Object[] keysAndValues); static void setAddon(String addonClassName); static void setAddon(Class<?> addonClass); static void setAddon(LookAndFeelAddons addon); static LookAndFeelAddons getAddon(); static String getBestMatchAddonClassName(); static String getCrossPlatformAddonClassName(); static String getSystemAddonClassName(); static void contribute(ComponentAddon component); static void uncontribute(ComponentAddon component); static ComponentUI getUI(JComponent component, Class<?> expectedUIClass); static synchronized void setTrackingLookAndFeelChanges(boolean tracking); static synchronized boolean isTrackingLookAndFeelChanges(); static void installBackgroundPainter(JComponent c, String painter); static void uninstallBackgroundPainter(JComponent c);  }
@Test public void testIssue144() throws Exception { UIManager.put("Addon.title", "customized"); UIManager.put("Addon.border", new LineBorder(Color.blue)); Addon addon = new Addon(); LookAndFeelAddons.contribute(addon); assertEquals("customized", UIManager.get("Addon.title")); assertEquals("my subtitle", UIManager.get("Addon.subtitle")); assertTrue(UIManager.get("Addon.border") instanceof LineBorder); UIManager.put("Addon.title", null); assertEquals("my title", UIManager.get("Addon.title")); }
@Test public void testContribute() throws Exception { Addon addon = new Addon(); LookAndFeelAddons.contribute(addon); assertTrue(addon.initialized); LookAndFeelAddons.uncontribute(addon); assertTrue(addon.uninitialized); LookAndFeelAddons.contribute(addon); addon.initialized = false; addon.uninitialized = false; LookAndFeelAddons oldLFAddon = LookAndFeelAddons.getAddon(); LookAndFeelAddons.setAddon(MetalLookAndFeelAddons.class); LookAndFeelAddons newLFAddon = LookAndFeelAddons.getAddon(); assertTrue(addon.uninitialized); assertEquals(oldLFAddon, addon.uninitializedWith); assertTrue(addon.initialized); assertEquals(newLFAddon, addon.initializedWith); }
@Test public void testUpdateUIForReferredProperties() throws Exception { LookAndFeelAddons.contribute(new Addon()); Color panelBackground = UIManager.getColor("Panel.background"); assertThat(UIManager.getColor("Addon.panelBackground"), is(panelBackground)); UIManager.put("Panel.background", new ColorUIResource(panelBackground.darker())); assertThat(UIManager.getColor("Addon.panelBackground"), is(panelBackground)); }