Package com.github.weisj.darklaf.icons
Class DarkUIAwareIcon
java.lang.Object
com.github.weisj.darklaf.icons.DarkUIAwareIcon
- All Implemented Interfaces:
DynamicIcon,UIAwareIcon,Serializable,Icon,UIResource
Icon that is aware of the current ui theme and adjusts the icon accordingly. Icons are loaded
lazily at their point of usage.
- Since:
- 2019
- See Also:
- Serialized Form
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDarkUIAwareIcon(String darkKey, String lightKey, int w, int h, Class<?> parentClass)Create new ui aware icon. -
Method Summary
-
Field Details
-
darkKey
-
lightKey
-
w
protected final int w -
h
protected final int h -
parentClass
-
loaded
protected transient boolean loaded -
icon
-
-
Constructor Details
-
DarkUIAwareIcon
Create new ui aware icon.- Parameters:
darkKey- key to load icon for dark mode.lightKey- key to load icon for light mode.w- width of icon.h- height of icon.parentClass- the class to resolve the path while lazy loading.
-
-
Method Details
-
paintIcon
-
ensureLoaded
protected void ensureLoaded() -
updateStyle
protected void updateStyle() -
isLoaded
protected boolean isLoaded() -
isDark
public boolean isDark() -
loadIcon
protected void loadIcon() -
paintIcon
-
getIconWidth
public int getIconWidth()- Specified by:
getIconWidthin interfaceIcon
-
getIconHeight
public int getIconHeight()- Specified by:
getIconHeightin interfaceIcon
-
getDual
Description copied from interface:UIAwareIconReturn the dual version of the icon. i.e. if the current icon is light then the dual version will be dark and vice versa. Implementations of this method should respect that the appearance of the icon after invoking this method twice should be the same.- Specified by:
getDualin interfaceUIAwareIcon- Returns:
- the dual icon.
-