Class WIconPair
- java.lang.Object
-
- eu.webtoolkit.jwt.WObject
-
- eu.webtoolkit.jwt.WWidget
-
- eu.webtoolkit.jwt.WCompositeWidget
-
- eu.webtoolkit.jwt.WIconPair
-
public class WIconPair extends WCompositeWidget
A widget that shows one of two icons depending on its state.This is a utility class that simply manages two images, only one of which is shown at a single time, which reflects the current 'state'.
The widget may react to click events, by changing state.
CSS
This widget does not provide styling, and can be styled using inline or external CSS as appropriate. The image may be styled via the
<img>elements.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWIconPair.IconTypeAn enumeration describing a type of icon.-
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
-
Field Summary
-
Fields inherited from class eu.webtoolkit.jwt.WWidget
WT_GETEXTRAMS_JS
-
-
Constructor Summary
Constructors Constructor Description WIconPair(java.lang.String icon1Str, java.lang.String icon2Str)Construct an icon pair from the two icons.WIconPair(java.lang.String icon1Str, java.lang.String icon2Str, boolean clickIsSwitch)Construct an icon pair from the two icons.WIconPair(java.lang.String icon1Str, java.lang.String icon2Str, boolean clickIsSwitch, WContainerWidget parentContainer)Construct an icon pair from the two icons.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WImagegetIcon1()WImagegetIcon2()WIcongetIconNameIcon1()Returns the first icon asWIcon.WIcongetIconNameIcon2()Returns the second icon asWIcon.intgetState()Returns the current state.WImagegetUriIcon1()Returns the first icon asWImage.WImagegetUriIcon2()Returns the second icon asWImage.EventSignal1<WMouseEvent>icon1Clicked()Signal emitted when clicked while in state 0 (icon 1 is shown).EventSignal1<WMouseEvent>icon2Clicked()Signal emitted when clicked while in state 1 (icon 2 is shown).voidsetIcon1Type(WIconPair.IconType type)Sets the IconType of the first icon.voidsetIcon2Type(WIconPair.IconType type)Sets the IconType of the second icon.voidsetIconsType(WIconPair.IconType type)Sets the IconType of the both icons.voidsetState(int num)Sets the state, which determines the visible icon.voidshowIcon1()Sets the state to 0 (show icon 1).voidshowIcon2()Sets the state to 1 (show icon 2).-
Methods inherited from class eu.webtoolkit.jwt.WCompositeWidget
addStyleClass, boxBorder, boxPadding, callJavaScriptMember, doJavaScript, enableAjax, find, findById, getAttributeValue, getBaseZIndex, getChildren, getClearSides, getDecorationStyle, getFloatSide, getHeight, getId, getImplementation, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getObjectName, getOffset, getPositionScheme, getScrollVisibilityMargin, getStyleClass, getTabIndex, getTakeImplementation, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, hasFocus, hasStyleClass, isCanReceiveFocus, isDisabled, isEnabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isScrollVisibilityEnabled, isScrollVisible, isSetFirstFocus, isThemeStyleEnabled, isVisible, load, propagateSetEnabled, propagateSetVisible, refresh, remove, removeStyleClass, removeWidget, render, resize, scrollVisibilityChanged, setAttributeValue, setCanReceiveFocus, setClearSides, setDecorationStyle, setDeferredToolTip, setDisabled, setFloatSide, setFocus, setHidden, setHiddenKeepsGeometry, setId, setImplementation, setInline, setJavaScriptMember, setLineHeight, setMargin, setMaximumSize, setMinimumSize, setObjectName, setOffsets, setParentWidget, setPopup, setPositionScheme, setScrollVisibilityEnabled, setScrollVisibilityMargin, setSelectable, setStyleClass, setTabIndex, setThemeStyleEnabled, setToolTip, setVerticalAlignment
-
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, applyThemeStyles, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, isRendered, layoutSizeChanged, needsRerender, positionAt, positionAt, positionAt, positionAt, removeFromParent, removeStyleClass, render, resize, scheduleRender, scheduleRender, scheduleRender, scheduleThemeStyleApply, setClearSides, setDeferredToolTip, setFocus, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
-
Methods inherited from class eu.webtoolkit.jwt.WObject
setFormData
-
-
-
-
Constructor Detail
-
WIconPair
public WIconPair(java.lang.String icon1Str, java.lang.String icon2Str, boolean clickIsSwitch, WContainerWidget parentContainer)Construct an icon pair from the two icons.The constructor takes the URL or the Font Awesome name of the two icons. When
clickIsSwitchis settrue, clicking on the icon will switch state.Note: The Font Aweswome name can be followed by sizing information separated by a space if the Font Aweswome version used allows it. A valid icon can look like this for example:
"fa-solid fa-camera fa-1x", or"fa-solid fa-camera fa-sm"(valid for version v6.7.2). More sizing information can be found on https://docs.fontawesome.com/web/style/size.Warning: By default, the strings are considered to represent the URIs of the icons. Use
setIcon1Type()andsetIcon2Type()to change the IconType accordingly if it is not what the string represents. Both can be set at once using setIconTypes().
-
WIconPair
public WIconPair(java.lang.String icon1Str, java.lang.String icon2Str)Construct an icon pair from the two icons.Calls
this(icon1Str, icon2Str, true, (WContainerWidget)null)
-
WIconPair
public WIconPair(java.lang.String icon1Str, java.lang.String icon2Str, boolean clickIsSwitch)Construct an icon pair from the two icons.Calls
this(icon1Str, icon2Str, clickIsSwitch, (WContainerWidget)null)
-
-
Method Detail
-
setIcon1Type
public void setIcon1Type(WIconPair.IconType type)
Sets the IconType of the first icon.- See Also:
setIconsType(WIconPair.IconType type)
-
setIcon2Type
public void setIcon2Type(WIconPair.IconType type)
Sets the IconType of the second icon.- See Also:
setIconsType(WIconPair.IconType type)
-
setIconsType
public void setIconsType(WIconPair.IconType type)
-
setState
public void setState(int num)
Sets the state, which determines the visible icon.The first icon has number 0, and the second icon has number 1.
The default state is 0.
- See Also:
getState()
-
getState
public int getState()
Returns the current state.- See Also:
setState(int num)
-
getIcon1
public WImage getIcon1()
-
getIcon2
public WImage getIcon2()
-
getUriIcon1
public WImage getUriIcon1()
Returns the first icon asWImage.If first icon type is
URIreturns the first icon asWImage, otherwise returns nullptr.- See Also:
getIconNameIcon1()
-
getUriIcon2
public WImage getUriIcon2()
Returns the second icon asWImage.If second icon type is
URIreturns the second icon asWImage, otherwise returns nullptr.- See Also:
getIconNameIcon2()
-
getIconNameIcon1
public WIcon getIconNameIcon1()
Returns the first icon asWIcon.If first icon type is
IconNamereturns the first icon asWIcon, otherwise returns nullptr.- See Also:
getUriIcon1()
-
getIconNameIcon2
public WIcon getIconNameIcon2()
Returns the second icon asWIcon.If second icon type is
IconNamereturns the second icon asWIcon, otherwise returns nullptr.- See Also:
getUriIcon2()
-
showIcon1
public void showIcon1()
Sets the state to 0 (show icon 1).- See Also:
setState(int num)
-
showIcon2
public void showIcon2()
Sets the state to 1 (show icon 2).- See Also:
setState(int num)
-
icon1Clicked
public EventSignal1<WMouseEvent> icon1Clicked()
Signal emitted when clicked while in state 0 (icon 1 is shown).Equivalent to:
icon1().clicked()
-
icon2Clicked
public EventSignal1<WMouseEvent> icon2Clicked()
Signal emitted when clicked while in state 1 (icon 2 is shown).Equivalent to:
icon2().clicked()
-
-