Package ej.widget.basic
Class ImageButton
- java.lang.Object
-
- ej.mwt.Widget
-
- ej.widget.basic.ImageWidget
-
- ej.widget.basic.ImageButton
-
- All Implemented Interfaces:
Clickable
public class ImageButton extends ImageWidget implements Clickable
An image button is a widget that displays an image and reacts to click events.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ej.mwt.Widget
Widget.WidgetListener
-
-
Field Summary
-
Fields inherited from class ej.mwt.Widget
DEBUG_WIDGET_ENABLED_CONSTANT, DEBUG_WIDGET_MONITOR_CONSTANT, NO_CONSTRAINT
-
-
Constructor Summary
Constructors Constructor Description ImageButton(String imagePath)Creates an image button with the resource path of the image to display.ImageButton(String imagePath, ResourceImage.OutputFormat outputFormat)Creates an image button with the resource path and the output format of the image to display.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanhandleEvent(int event)Handles the given event.booleanisInState(int state)Gets whether or not the widget is in the given state.voidsetOnClickListener(OnClickListener listener)Sets the listener on the click events of this button.voidsetPressed(boolean pressed)Changes the clickable element state.-
Methods inherited from class ej.widget.basic.ImageWidget
computeContentOptimalSize, onAttached, onDetached, renderContent, setImagePath
-
Methods inherited from class ej.mwt.Widget
addClassSelector, contains, containsWidget, getAbsoluteX, getAbsoluteY, getContentBounds, getDesktop, getHeight, getParent, getStyle, getWidgetAt, getWidth, getX, getY, hasClassSelector, isAttached, isEnabled, isShown, isTransparent, onHidden, onLaidOut, onShown, removeAllClassSelectors, removeClassSelector, render, requestLayOut, requestRender, requestRender, setClassSelectors, setEnabled, setPosition, setStyle, setX, setY, updateStyle
-
-
-
-
Constructor Detail
-
ImageButton
public ImageButton(String imagePath)
Creates an image button with the resource path of the image to display.- Parameters:
imagePath- the resource path of the image to display.
-
ImageButton
public ImageButton(String imagePath, ResourceImage.OutputFormat outputFormat)
Creates an image button with the resource path and the output format of the image to display.- Parameters:
imagePath- the resource path of the image to display.outputFormat- the output format of the image to display.
-
-
Method Detail
-
setOnClickListener
public void setOnClickListener(@Nullable OnClickListener listener)
Sets the listener on the click events of this button.- Parameters:
listener- the listener to set.
-
isInState
public boolean isInState(int state)
Description copied from class:WidgetGets whether or not the widget is in the given state.
-
handleEvent
public boolean handleEvent(int event)
Description copied from class:WidgetHandles the given event. Does nothing by default and returnsfalse(does not consume event).Called by the desktop event manager.
- Overrides:
handleEventin classWidget- Parameters:
event- the event to handle.- Returns:
trueif the widget has consumed the event,falseotherwise.
-
setPressed
public void setPressed(boolean pressed)
Description copied from interface:ClickableChanges the clickable element state.- Specified by:
setPressedin interfaceClickable- Parameters:
pressed-trueif the element is pressed,falseotherwise.
-
-