The solution creates an instance of LookAndFeel by default (which should never be executed according to Javadocs). You can then get the default user interface from LaF and apply it to your button.
If this code was tested in my own application, which also uses the substance, and it worked:
LookAndFeel laf = null; try { String lafClassName = UIManager.getSystemLookAndFeelClassName(); laf = (LookAndFeel) (Class.forName(lafClassName).newInstance()); } catch (ClassNotFoundException ex) { } catch (InstantiationException ex) { } catch (IllegalAccessException ex) { } if (laf != null) { laf.initialize(); button.setUI((ButtonUI) laf.getDefaults().getUI(button)); }
If you want to switch between different substances, you can use SKIN_PROPERTY .
source share