use of com.github.weisj.darklaf.properties.icons.IconLoader in project darklaf by weisJ.
the class IconCacheTest method testIconCacheGetsReleased.
@Test
void testIconCacheGetsReleased() {
IconLoader iconLoader = (IconLoader) IconSet.iconLoader();
iconLoader.clearCache();
UIDefaults defaults = new DarkLaf().getDefaults();
Assertions.assertFalse(iconLoader.isCacheEmpty());
int size = iconLoader.cacheSize();
defaults.clear();
waitForGarbageCollection(() -> iconLoader.cacheSize() == size);
}
use of com.github.weisj.darklaf.properties.icons.IconLoader in project darklaf by weisJ.
the class IconDemo method createComponent.
@Override
public JComponent createComponent() {
iconPanel = new JPanel(new GridLayout(3, 2, LayoutHelper.getDefaultSpacing(), LayoutHelper.getDefaultSpacing()));
iconPanel.setBorder(LayoutHelper.createEmptyContainerBorder());
UIManager.put("TestIcon.color", new Color(255, 35, 181));
IconLoader iconLoader = IconLoader.get(IconDemo.class);
UIAwareIcon uiAwareImageIcon = iconLoader.getUIAwareIcon("aware_image_icon.png");
UIAwareIcon uiAwareImageIconDual = uiAwareImageIcon.getDual();
UIAwareIcon uiAwareIcon = iconLoader.getUIAwareIcon("aware_icon.svg");
UIAwareIcon uiAwareIconDual = uiAwareIcon.getDual();
Icon themedIcon = iconLoader.getIcon("themed_icon.svg", 16, 16, true);
Icon imageIcon = iconLoader.getIcon("image_icon.png");
iconPanel.add(new JLabel("Aware image icon", uiAwareImageIcon, JLabel.LEFT));
iconPanel.add(new JLabel("Aware image icon (dual)", uiAwareImageIconDual, JLabel.LEFT));
iconPanel.add(new JLabel("Aware svg icon", uiAwareIcon, JLabel.LEFT));
iconPanel.add(new JLabel("Aware svg icon (dual)", uiAwareIconDual, JLabel.LEFT));
iconPanel.add(new JLabel("Themed icon", themedIcon, JLabel.LEFT));
iconPanel.add(new JLabel("Image icon", imageIcon, JLabel.LEFT));
DemoPanel panel = new DemoPanel(iconPanel, new BorderLayout(), 0);
JPanel controlPanel = panel.addControls();
controlPanel.add(new JToggleButton("Light/Dark") {
{
LafManager.addThemeChangeListener((ThemeInstalledListener) e -> setSelected(Theme.isDark(e.getNewTheme())));
putClientProperty("JToggleButton.variant", "slider");
addActionListener(e -> updateAwareIconStyle());
}
});
controlPanel.add(new QuickColorChooser("Themed icon color", UIManager.getColor("TestIcon.color"), this::updateThemedIconColor));
return panel;
}
Aggregations