diff --git a/pom.xml b/pom.xml
index ba433334..960e6caf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -162,6 +162,11 @@
sc.fiji
fiji-lib
+
+ com.formdev
+ flatlaf
+ provided
+
diff --git a/src/main/java/trainableSegmentation/SymbolIcon.java b/src/main/java/trainableSegmentation/SymbolIcon.java
new file mode 100644
index 00000000..bd34e3c2
--- /dev/null
+++ b/src/main/java/trainableSegmentation/SymbolIcon.java
@@ -0,0 +1,83 @@
+/*-
+ * #%L
+ * Fiji distribution of ImageJ for the life sciences.
+ * %%
+ * Copyright (C) 2010 - 2024 Fiji developers.
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * .
+ * #L%
+ */
+package trainableSegmentation;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+
+import javax.swing.Icon;
+import javax.swing.UIManager;
+
+import com.formdev.flatlaf.FlatLaf.DisabledIconProvider;;
+
+/**
+ * Unicode symbol as Icon
+ */
+public class SymbolIcon implements Icon, DisabledIconProvider {
+ private String symbol = null;
+ private int size;
+
+ /**
+ *
+ */
+ public SymbolIcon(String symbol) {
+ this(symbol, 16);
+ }
+
+ public SymbolIcon(String symbol, int size) {
+ this.symbol = symbol;
+ this.size = size;
+ }
+
+ @Override
+ public int getIconHeight() {
+ return size;
+ }
+
+ @Override
+ public int getIconWidth() {
+ return size;
+ }
+
+ @Override
+ public void paintIcon(Component c, Graphics g, int x, int y) {
+ final Font oldFont = g.getFont();
+ final float fs = size/1.1f;
+ g.setFont(oldFont.deriveFont(fs));
+ final Color color = UIManager.getColor(c.isEnabled() ? "textText" : "textInactiveText");
+ g.setColor(color);
+ if (g instanceof Graphics2D)
+ ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
+ RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
+ g.drawString(symbol, x, y+(int)fs);
+ g.setFont(oldFont);
+ }
+
+ @Override
+ public Icon getDisabledIcon() {
+ return this;
+ }
+}
diff --git a/src/main/java/trainableSegmentation/Weka_Segmentation.java b/src/main/java/trainableSegmentation/Weka_Segmentation.java
index a9e4db34..d44c3398 100644
--- a/src/main/java/trainableSegmentation/Weka_Segmentation.java
+++ b/src/main/java/trainableSegmentation/Weka_Segmentation.java
@@ -221,7 +221,7 @@ public class Weka_Segmentation implements PlugIn
private JButton [] addExampleButton = null;
private JButton[] addExampleExtras = null; // consider JideSplitButton?
private final JPopupMenu addExampleMenu = new JPopupMenu();
- private final JMenuItem exampleColor = new JMenuItem(new AbstractAction("🎨 Change color…") {
+ private final JMenuItem exampleColor = new JMenuItem(new AbstractAction("Change color…", new SymbolIcon("🎨")) {
private static final long serialVersionUID = 1L;
{
putValue(Action.SHORT_DESCRIPTION, "Change class and traces color");
@@ -239,7 +239,7 @@ public void actionPerformed(ActionEvent e) {
IJ.showMessage("Failed to look up class " + label + " for color change");
}
});
- private final JMenuItem exampleRename = new JMenuItem(new AbstractAction("✎ Rename class…") {
+ private final JMenuItem exampleRename = new JMenuItem(new AbstractAction("Rename class…", new SymbolIcon("✎")) {
private static final long serialVersionUID = 1L;
{
putValue(Action.SHORT_DESCRIPTION, "Change class label");
@@ -259,7 +259,7 @@ public void actionPerformed(ActionEvent e) {
IJ.showMessage("Failed to look up class " + label + " for label change");
}
});
- private final JMenuItem exampleRemove = new JMenuItem(new AbstractAction("✘ Remove class") {
+ private final JMenuItem exampleRemove = new JMenuItem(new AbstractAction("Remove class", new SymbolIcon("✘")) {
private static final long serialVersionUID = 1L;
{
putValue(Action.SHORT_DESCRIPTION, "Remove class and all associated traces");
@@ -285,7 +285,7 @@ public void actionPerformed(ActionEvent e) {
});
/** Tag for class label name in addExampleExtras' client property bag */
private final Object labelTag = new Object();
- private final JButton saveExamplesButton = new JButton(new AbstractAction("💾 Save…") {
+ private final JButton saveExamplesButton = new JButton(new AbstractAction("Save…", new SymbolIcon("💾")) {
private static final long serialVersionUID = 1L;
{
putValue(Action.SHORT_DESCRIPTION, "Save example ROI traces");
@@ -298,7 +298,7 @@ public void actionPerformed(ActionEvent e) {
}
});
- private final JButton loadExamplesButton = new JButton(new AbstractAction("📂 Load…") {
+ private final JButton loadExamplesButton = new JButton(new AbstractAction("Load…", new SymbolIcon("📂")) {
private static final long serialVersionUID = 1L;
{
putValue(Action.SHORT_DESCRIPTION, "Load example ROI traces");
@@ -798,13 +798,6 @@ private class CustomWindow extends StackWindow
setTitle( Weka_Segmentation.PLUGIN_NAME + " " + Weka_Segmentation.PLUGIN_VERSION );
- // remove space for a menu item icon in default look and feel
- // https://stackoverflow.com/a/64590818/673826
- // https://github.com/JFormDesigner/FlatLaf/issues/328
- final Insets insets = new Insets(2, -8, 2, 2);
- exampleColor.setMargin(insets);
- exampleRename.setMargin(insets);
- exampleRemove.setMargin(insets);
addExampleMenu.add(exampleColor);
addExampleMenu.add(exampleRename);
addExampleMenu.addSeparator();