iconSizeProperty and fontSize seem indepentend but are not. If you bind iconSizeProperty and then try to set the font, you get an exception.
FontIcon fontIcon = new FontIcon("mdi2m-magnify");
fontIcon.iconSizeProperty().bind(new SimpleDoubleProperty(17));
fontIcon.setFont(new Font("Arial", 10));
java.lang.RuntimeException: FontIcon.iconSize : A bound value cannot be set.
at javafx.beans.property.IntegerPropertyBase.set(IntegerPropertyBase.java:144)
at javafx.css.StyleableIntegerProperty.set(StyleableIntegerProperty.java:82)
at org.kordamp.ikonli.javafx.FontIcon.setIconSize(FontIcon.java:213)
at org.kordamp.ikonli.javafx.FontIcon.lambda$new$0(FontIcon.java:63)
at com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:181)
at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
FontIcon extends Text, which makes it eligible for css styling. The css engine will try to set the font, and procudes this stack trace for me:
java.lang.RuntimeException: FontIcon.iconSize : A bound value cannot be set.
at javafx.beans.property.IntegerPropertyBase.set(IntegerPropertyBase.java:144)
at javafx.css.StyleableIntegerProperty.set(StyleableIntegerProperty.java:82)
at org.kordamp.ikonli.javafx.FontIcon.setIconSize(FontIcon.java:213)
at org.kordamp.ikonli.javafx.FontIcon.lambda$new$0(FontIcon.java:63)
at com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:181)
at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
at javafx.beans.property.ObjectPropertyBase.fireValueChangedEvent(ObjectPropertyBase.java:106)
at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:113)
at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:147)
at javafx.css.StyleableObjectProperty.set(StyleableObjectProperty.java:82)
at javafx.css.StyleableObjectProperty.applyStyle(StyleableObjectProperty.java:68)
at javafx.scene.CssStyleHelper.transitionToState(CssStyleHelper.java:954)
at javafx.scene.Node.doProcessCSS(Node.java:9574)
at javafx.scene.Node$1.doProcessCSS(Node.java:481)
at com.sun.javafx.scene.NodeHelper.processCSSImpl(NodeHelper.java:193)
at com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:146)
at javafx.scene.Parent.doProcessCSS(Parent.java:1400)
at javafx.scene.Parent$1.doProcessCSS(Parent.java:125)
at com.sun.javafx.scene.ParentHelper.processCSSImpl(ParentHelper.java:98)
at com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:146)
at javafx.scene.Node.processCSS(Node.java:9456)
at javafx.scene.Node.processCSS(Node.java:9449)
at javafx.scene.Scene.doCSSPass(Scene.java:572)
at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2510)
at com.sun.javafx.tk.Toolkit.lambda$runPulse$2(Toolkit.java:423)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:422)
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:452)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:575)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:555)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:548)
at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$11(QuantumToolkit.java:353)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:290)
at java.base/java.lang.Thread.run(Thread.java:833)
As a workaround I will opt out of binding and properties on Ikonli objects.
This was created on
- openjdk version "17.0.9" 2023-10-17
with maven dependencies
<dependency>
<groupId>org.kordamp.ikonli</groupId>
<artifactId>ikonli-javafx</artifactId>
<version>12.3.1</version>
</dependency>
<dependency>
<groupId>org.kordamp.ikonli</groupId>
<artifactId>ikonli-materialdesign2-pack</artifactId>
<version>12.3.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
<version>17.0.6</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>17.0.6</version>
</dependency>
iconSizePropertyandfontSizeseem indepentend but are not. If you bindiconSizePropertyand then try to set the font, you get an exception.FontIconextendsText, which makes it eligible for css styling. The css engine will try to set the font, and procudes this stack trace for me:As a workaround I will opt out of binding and properties on Ikonli objects.
This was created on
with maven dependencies