Package ej.widget.basic
Class ImageWidget
- java.lang.Object
-
- ej.mwt.Widget
-
- ej.widget.basic.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.
-
-
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
-
-
-
-
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 classej.mwt.Widget
-
onDetached
protected void onDetached()
- Overrides:
onDetached
in classej.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 classej.mwt.Widget
-
computeContentOptimalSize
protected void computeContentOptimalSize(ej.mwt.util.Size size)
- Specified by:
computeContentOptimalSize
in classej.mwt.Widget
-
-