Search code examples
javafxgluon-mobile

How can I set Icon on Gluon Mobile based project?


Since the start() method is final (cannot be overridden), and primaryStage has a private access in Mobile Application how can I set Icon on my program?


Solution

  • You can define a list of icons to a Stage instance:

    primaryStage.getIcons().addAll(icon1, icon2, ...);
    

    , where icon1, icon2 are instances of the Image class. The Image Javadoc explains that BMP, PNG, GIF and JPEG are the required formats but if I remember well, you can add a picture with the ICO format: icon1 = new Image("/.../logo.ico");

    You can add all your icons to your application using that method. As explained in the Javadoc :

    The images should be different sizes of the same image and the best size will be chosen, eg. 16x16, 32,32.