I am trying to use FlatLaf theme in my OSGI services. Currently calling FlatDarkLaf.setup()
in the first service that initializing. It is working perfectly fine in the same service but outside of that, some swing components could not find UI Classes as example below.
java.lang.Error: no ComponentUI class for: javax.swing.JOptionPane[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=,preferredSize=,icon=,initialValue=,message=com.ekinokssoftware.kabintester.common.AddTakePanel[,0,0,0x0,invalid,layout=java.awt.GridBagLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=],messageType=QUESTION_MESSAGE,optionType=YES_NO_CANCEL_OPTION,wantsInput=false]
at java.desktop/javax.swing.UIDefaults.getUIError(UIDefaults.java:763)
at java.desktop/javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:144)
at java.desktop/javax.swing.UIDefaults.getUI(UIDefaults.java:793)
at java.desktop/javax.swing.UIManager.getUI(UIManager.java:1072)
at java.desktop/javax.swing.JOptionPane.updateUI(JOptionPane.java:1880)
at java.desktop/javax.swing.JOptionPane.<init>(JOptionPane.java:1845)
at java.desktop/javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:869)
at java.desktop/javax.swing.JOptionPane.showConfirmDialog(JOptionPane.java:806)
at java.desktop/javax.swing.JOptionPane.showConfirmDialog(JOptionPane.java:768)
at java.desktop/javax.swing.JOptionPane.showConfirmDialog(JOptionPane.java:729)
at java.desktop/javax.swing.JOptionPane.showConfirmDialog(JOptionPane.java:700)
I am suspecting this is some kind of ClassLoader problem but don't know how to approach since there are no information about FlatLaf with OSGI. Calling FlatDarkLaf.setup()
in each service also didn't help.
Adding the service that calls FlatDarkLaf.setup()
to the required bundles in all services that use UI components resolved the issue.