diff --git a/src/dorkbox/systemTray/swingUI/SwingMenuItemCheckbox.java b/src/dorkbox/systemTray/swingUI/SwingMenuItemCheckbox.java index 114f3b6..6c32912 100644 --- a/src/dorkbox/systemTray/swingUI/SwingMenuItemCheckbox.java +++ b/src/dorkbox/systemTray/swingUI/SwingMenuItemCheckbox.java @@ -60,8 +60,14 @@ class SwingMenuItemCheckbox extends SwingMenuItem implements CheckboxPeer { int sizePadding = (menuImageSize - size) / 2; - checkedIcon = new ImageIcon(HeavyCheckMark.get(jMenuItem.getForeground(), size, - 0, sizePadding, 0, sizePadding)); + String checkmarkPath; + if (SystemTray.SWING_UI != null) { + checkmarkPath = SystemTray.SWING_UI.getCheckMarkIcon(jMenuItem.getForeground(), size, 0, sizePadding, 0, sizePadding); + } else { + checkmarkPath = HeavyCheckMark.get(jMenuItem.getForeground(), size, 0, sizePadding, 0, sizePadding); + } + + checkedIcon = new ImageIcon(checkmarkPath); } catch(Exception e) { SystemTray.logger.error("Error creating check-mark image.", e); } diff --git a/src/dorkbox/systemTray/swingUI/SwingUIFactory.java b/src/dorkbox/systemTray/swingUI/SwingUIFactory.java index f5f1b96..0cee1eb 100644 --- a/src/dorkbox/systemTray/swingUI/SwingUIFactory.java +++ b/src/dorkbox/systemTray/swingUI/SwingUIFactory.java @@ -15,6 +15,8 @@ */ package dorkbox.systemTray.swingUI; +import java.awt.Color; + import javax.swing.JMenuItem; import javax.swing.JPopupMenu; import javax.swing.JSeparator; @@ -67,4 +69,20 @@ interface SwingUIFactory { * @return the UI used to customize the Look & Feel of a menu separator entry */ SeparatorUI getSeparatorUI(JSeparator jSeparator); + + /** + * Get the path to a CheckMark image for a specified color, size, and padding. + *

+ * This is necessary because Swing does not have correct spacing when rendering CheckMark menu items next to + * normal menu menu items (with, or without, images attached). + * + * @param color the color of the CheckMark + * @param checkMarkSize the size of the CheckMark inside the image. (does not include padding) + * + * @param paddingTop amount of padding to apply to the top edge of the icon. + * @param paddingLeft amount of padding to apply to the left edge of the icon. + * @param paddingBottom amount of padding to apply to the bottom edge of the icon. + * @param paddingRight amount of padding to apply to the right edge of the icon. + */ + String getCheckMarkIcon(Color color, int checkMarkSize, int paddingTop, int paddingLeft , int paddingBottom, int paddingRight); } diff --git a/src/dorkbox/systemTray/util/HeavyCheckMark.java b/src/dorkbox/systemTray/util/HeavyCheckMark.java index e7015d2..fb72f48 100644 --- a/src/dorkbox/systemTray/util/HeavyCheckMark.java +++ b/src/dorkbox/systemTray/util/HeavyCheckMark.java @@ -21,7 +21,7 @@ public class HeavyCheckMark { private static final int VERSION = 1; /** - * This saves a scalable CheckMark to a correctly sized PNG file. + * This saves a vector CheckMark to a correctly sized PNG file. * * @param color the color of the CheckMark * @param checkMarkSize the size of the CheckMark inside the image. (does not include padding)