11package  de .felixroske .jfxsupport ;
22
3+ import  java .util .ArrayList ;
4+ import  java .util .List ;
5+ 
36import  org .springframework .boot .SpringApplication ;
47import  org .springframework .context .ConfigurableApplicationContext ;
8+ import  org .springframework .core .env .Environment ;
59
610import  javafx .application .Application ;
711import  javafx .scene .Scene ;
@@ -22,7 +26,7 @@ public abstract class AbstractJavaFxApplicationSupport extends Application {
2226	private  static  Stage  stage ;
2327	private  static  Scene  scene ; 
2428
25- 	protected  static  Image   icon ;
29+ 	protected  static  List < Image >  icons  =  new   ArrayList <>() ;
2630
2731    public  static  Stage  getStage () {
2832        return  stage ;
@@ -31,11 +35,36 @@ public static Stage getStage() {
3135    public  static  Scene  getScene () {
3236        return  scene ;
3337    }
38+ 
39+     private  List <String > propertyArrayReader (Environment  env , String  propName ) {
40+         ArrayList <String > list  = new  ArrayList <>();
41+         int  counter =0 ; 
42+         String  prop  = env .getProperty (propName +"["  + counter  + "]" );
43+         
44+         while (prop  != null ) {
45+             list .add (prop );
46+             counter ++;
47+             prop  = env .getProperty (propName +"["  + counter  + "]" );
48+         }
49+         
50+         return  list ;
51+     }
3452
3553	@ Override 
3654	public  void  init () throws  Exception  {
3755		applicationContext  = SpringApplication .run (getClass (), savedArgs );
38- 		icon  = new  Image (getClass ().getResource ("/icon.png" ).toExternalForm ());
56+ 		List <String > fsImages  = propertyArrayReader (applicationContext .getEnvironment (), "javafx.appicons" );
57+ 		
58+ 		if (!fsImages .isEmpty ()) {
59+ 		    fsImages .forEach ((s ) -> icons .add (new  Image (getClass ().getResource (s ).toExternalForm ())));
60+ 		}
61+ 		else  { // add factory images 
62+ 		    icons .add (new  Image (getClass ().getResource ("/icons/gear_16x16.png" ).toExternalForm ()));
63+ 		    icons .add (new  Image (getClass ().getResource ("/icons/gear_24x24.png" ).toExternalForm ()));
64+ 		    icons .add (new  Image (getClass ().getResource ("/icons/gear_36x36.png" ).toExternalForm ()));
65+ 		    icons .add (new  Image (getClass ().getResource ("/icons/gear_42x42.png" ).toExternalForm ()));
66+ 		    icons .add (new  Image (getClass ().getResource ("/icons/gear_64x64.png" ).toExternalForm ()));
67+ 		}
3968	}
4069
4170	@ Override 
@@ -55,8 +84,7 @@ public static void showView(Class<? extends AbstractFxmlView> newView) {
5584			scene .setRoot (view .getView ());
5685		}
5786
58- 		// stage.setTitle(windowTitle); 
59- 		stage .getIcons ().add (icon );
87+ 		stage .getIcons ().addAll (icons );
6088		stage .setScene (scene );
6189//		stage.setResizable(true); 
6290//		stage.centerOnScreen(); 
0 commit comments