Class ImageWidget

  • Direct Known Subclasses:
    ImageButton

    public class ImageWidget
    extends ej.mwt.Widget
    A widget that displays a resource image.

    The widget holds a path to the image. The actual image is allocated only when the widget is attached. It is also closed when the widget is detached.

    • Field Summary

      • Fields inherited from class ej.mwt.Widget

        NO_CONSTRAINT
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        ImageWidget​(java.lang.String imagePath)
      Creates an image widget with the resource path of the image to display.
      protected ImageWidget​(java.lang.String imagePath, boolean enabled)
      Creates an image widget with the resource path of the image to display and its enabled state.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void computeContentOptimalSize​(ej.mwt.util.Size size)  
      protected void onAttached()  
      protected void onDetached()  
      protected void renderContent​(ej.microui.display.GraphicsContext g, int contentWidth, int contentHeight)  
      void setImagePath​(java.lang.String imagePath)
      Sets the image path.
      • Methods inherited from class ej.mwt.Widget

        addClassSelector, contains, containsWidget, getAbsoluteX, getAbsoluteY, getContentBounds, getDesktop, getHeight, getParent, getStyle, getWidgetAt, getWidth, getX, getY, handleEvent, hasClassSelector, isAttached, isEnabled, isInState, isShown, isTransparent, onHidden, onLaidOut, onShown, removeAllClassSelectors, removeClassSelector, render, requestLayOut, requestRender, requestRender, setClassSelectors, setEnabled, setPosition, setStyle, updateStyle
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ImageWidget

        public ImageWidget​(java.lang.String imagePath)
        Creates an image widget with the resource path of the image to display.
        Parameters:
        imagePath - the resource path of the image to display.
        Throws:
        java.lang.IllegalArgumentException - if the image cannot be loaded.
        See Also:
        ResourceImage.canLoadImage(String)
      • ImageWidget

        protected ImageWidget​(java.lang.String imagePath,
                              boolean enabled)
        Creates an image widget with the resource path of the image to display and its enabled state.
        Parameters:
        imagePath - the resource path of the image to display.
        enabled - true if this image widget is to be enabled, false otherwise.
        Throws:
        java.lang.IllegalArgumentException - if the image cannot be loaded.
        See Also:
        ResourceImage.canLoadImage(String)
    • Method Detail

      • onAttached

        protected void onAttached()
        Overrides:
        onAttached in class ej.mwt.Widget
      • onDetached

        protected void onDetached()
        Overrides:
        onDetached in class ej.mwt.Widget
      • setImagePath

        public void setImagePath​(java.lang.String imagePath)
        Sets the image path.
        Parameters:
        imagePath - the resource path of the image to display.
        Throws:
        java.lang.IllegalArgumentException - if the image cannot be loaded.
        See Also:
        ResourceImage.canLoadImage(String)
      • renderContent

        protected void renderContent​(ej.microui.display.GraphicsContext g,
                                     int contentWidth,
                                     int contentHeight)
        Specified by:
        renderContent in class ej.mwt.Widget
      • computeContentOptimalSize

        protected void computeContentOptimalSize​(ej.mwt.util.Size size)
        Specified by:
        computeContentOptimalSize in class ej.mwt.Widget