简体   繁体   中英

How to show image in Eclipse Scout?

How to show an image in scout form?

I want to show an image as logo in the desktop form, I tried imagefield and htmlfield, but i failed to find examples online.

Swing UI

Are you using the swing client?

Do you want to change the logo "Eclipse Scout" provided by default:

Eclipse Scout-Swing桌面

Read this: How to brand the swing client .

Image field

If you want to display an image somewhere in a form, consider using an Image Field . You will get something like what you see in this Preview form:

侦查应用程序示例

Check the example in this Form: ImageFieldForm (Scout demo: widgets application ).

The ImageField should work perfectly fine for your use case. We are currently in the process of creating a widget sample application [1] that addresses such questions.

have a look at the DefaultField [2] of this application. in this case you set the initial image as follows

    @Override
    protected String getConfiguredImageId() {
      return AbstractIcons.ApplicationLogo;
    }

You can also add your own icons in the shared plugin of your application and reference these accordingly.

To display an external image you can override method ExecInitField of your ImageField:

      try {
        URL url = getUrl(<URL TO YOUR IMAGE>);
        setImage(IOUtility.getContent(url.openStream()));
      }
      catch (Exception e) {
        e.printStackTrace();
        getImageURLField().setErrorStatus(e.getMessage());
      }

hope this helps

[1] https://github.com/BSI-Business-Systems-Integration-AG/scoutbook/blob/master/code/widgets/

[2] https://github.com/BSI-Business-Systems-Integration-AG/scoutbook/blob/master/code/widgets/org.eclipse.scout.widget.client/src/org/eclipse/scout/widget/client/ui/forms/ImageFieldForm.java

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM