eclipse-pluginswtwizardsmart-wizard

I have to set a image on wizard dialogue,classpath load this image, but image not displayed properly


I have to set a image on wizard dialogue in swt,classpath load this image but image not displayed properly. In my design create a composit in this composit create a lebel.there after in this lebel I want add an image.After that i will create a runnable jar.This jar will be executed with proper image. In my implementation part i have create a resources (src folder) within src folder and in this resources folder kept image which i need.Please find the below code,

   File file = new File("resources/Automatics_Logo.png");
   Image image = new Image(Display.getDefault(), file.getPath());

   Label lblNewLabel_4 = new Label(composite, SWT.NONE);
  lblNewLabel_4.setImage(SWTResourceManager.getImage(CheckSystemConfigurationAndInstallation.class,image.toString()));

enter image description here


Solution

  • Image imgSWT=null;  // Image class is the SWT Image class
            ImageDescriptor imgDesc=null;
            java.net.URL imgURL = IntroductionPage.class.getResource("/Automatics_Logo.png");
    
            if (imgURL != null) {
                imgDesc = ImageDescriptor.createFromURL(imgURL);
                imgSWT = imgDesc.createImage();