B4J Code Snippet Metro Style with JMetro

1. Download jmetro-4.0.jar and copy it to the additional libraries folder.
https://github.com/JFXtras/jfxtras-styles/releases

2. Add reference to the jar:
B4X:
#AdditionalJar: jmetro-4.0

3. Apply the theme:
B4X:
Dim jo As JavaObject
jo.InitializeNewInstance("jfxtras.styles.jmetro8.JMetro", Array("LIGHT")) 'or DARK
Dim jform As JavaObject = MainForm
jo.RunMethod("applyTheme", Array(jform.GetField("scene")))

Before

SS-2018-08-09_15.04.17.png


After

SS-2018-08-09_15.04.51.png


Make sure to test it carefully as the theme changes some of the style attributes that are set by the designer.
 

ivanomonti

Well-Known Member
Licensed User
Longtime User
I'm trying version 11.6.9 and it gives me error in the string applyTheme as method not found, I was wondering if this updated version you could use.
 

androh

Member
Licensed User
Longtime User
Updated code for new jMetro version:

B4X:
#AdditionalJar: jmetro-11.6.14.jar

B4X:
Dim jo As JavaObject
Dim jform As JavaObject = MainForm
jo.InitializeNewInstance("jfxtras.styles.jmetro.JMetro", Array(jform.GetField("scene"), "LIGHT")) 'or DARK
jo.RunMethod("reApplyTheme", Null)
 
Top