Getting the Checkmark file name can now be overridden by the
SWING_UI paramater.
This commit is contained in:
parent
fd492a74e9
commit
c989de8cd8
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
* <p>
|
||||
* 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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user