public void setIcons(final Icon regular, Icon inactive, Icon hovered) { if (regular == null) return; if (inactive == null) inactive = regular; if (hovered == null) hovered = regular; int width = Math.max(regular.getIconWidth(), inactive.getIconWidth()); width = Math.max(width, hovered.getIconWidth()); int height = Math.max(regular.getIconHeight(), inactive.getIconHeight()); height = Math.max(height, hovered.getIconHeight()); setPreferredSize(new Dimension(width, height)); myRegular = new CenteredIcon(regular, width, height); myHovered = new CenteredIcon(hovered, width, height); myInactive = new CenteredIcon(inactive, width, height); }
private Icon getTreeNodeIcon(final boolean expanded, final boolean selected, final boolean focused) { final boolean white = selected && focused; final Icon selectedIcon = getTreeSelectedExpandedIcon(); final Icon notSelectedIcon = getTreeExpandedIcon(); final int width = Math.max(selectedIcon.getIconWidth(), notSelectedIcon.getIconWidth()); final int height = Math.max(selectedIcon.getIconWidth(), notSelectedIcon.getIconWidth()); return new CenteredIcon(expanded ? (white ? getTreeSelectedExpandedIcon() : getTreeExpandedIcon()) : (white ? getTreeSelectedCollapsedIcon() : getTreeCollapsedIcon()), width, height, false); }
public void setIcons(final Icon regular, final Icon inactive, final Icon hovered) { int width = Math.max(regular.getIconWidth(), inactive.getIconWidth()); width = Math.max(width, hovered.getIconWidth()); int height = Math.max(regular.getIconHeight(), inactive.getIconHeight()); height = Math.max(height, hovered.getIconHeight()); setPreferredSize(new Dimension(width, height)); myRegular = new CenteredIcon(regular, width, height); myHovered = new CenteredIcon(hovered, width, height); myInactive = new CenteredIcon(inactive, width, height); }
private static Presentation wrapIcon(Presentation presentation) { Icon original = presentation.getIcon(); CenteredIcon centered = new CenteredIcon(original != null ? original : DEFAULT_ICON, 40, 40, false); presentation.setIcon(centered); return presentation; }