Class ImagePreview

All Implemented Interfaces:
EventListener, DisposeListener, PaintListener, Drawable, SWTEventListener

public class ImagePreview extends Canvas implements DisposeListener, PaintListener
Widget that displays an image.

Similar to a Label with image, but image is resized to fit the widget.

Image can be provided as InputStream.

As a shortcut, the widget can also read a file.

Setting the Image directly is not supported to avoid issues with ownership and disposal of such an image.

  • Constructor Details

    • ImagePreview

      public ImagePreview(Composite parent)
      Initialize empty
      Parameters:
      parent - Parent widget
  • Method Details

    • setImage

      public void setImage(String image_filename)
      Set image to display
      Parameters:
      image_filename - Full path to image file or null for no image
    • setImage

      public void setImage(InputStream image_stream)
      Set image to display
      Parameters:
      image_stream - Image stream
    • setMessage

      public void setMessage(String message)
      Set a message that is displayed on top of the image
      Parameters:
      message - Message to display or null
    • computeSize

      public Point computeSize(int wHint, int hHint)
      Overrides:
      computeSize in class Control
    • paintControl

      public void paintControl(PaintEvent e)
      Specified by:
      paintControl in interface PaintListener
    • widgetDisposed

      public void widgetDisposed(DisposeEvent e)
      Specified by:
      widgetDisposed in interface DisposeListener