public class ToggleWrapper extends Wrapper implements GenericListener
EMPTY_ELEMENT_ARRAY
Constructor and Description |
---|
ToggleWrapper()
Creates a toggle button with a default toggle model.
|
ToggleWrapper(ToggleModel toggle)
Creates a toggle button with a referent toggle model.
|
ToggleWrapper(ToggleModel toggle,
java.lang.String group)
Creates a toggle button with a referent toggle model and a group.
|
Modifier and Type | Method and Description |
---|---|
void |
addOnStateChangeListener(OnStateChangeListener listener)
Adds a listener on the state change event of the toggle.
|
void |
gainFocus() |
ToggleModel |
getToggle()
Gets the toggle.
|
boolean |
handleEvent(int event) |
boolean |
isChecked()
Gets whether or not the toggle button is checked.
|
boolean |
isInState(State state)
Gets whether or not the element is in the given state.
|
void |
lostFocus() |
void |
removeOnStateChangeListener(OnStateChangeListener listener)
Removes a listener on the state change event of the toggle.
|
void |
requestFocus() |
boolean |
requestFocus(int direction) |
void |
setChecked(boolean checked)
Sets the state of the toggle.
|
void |
setGroup(java.lang.String groupName)
Sets the group of this toggle.
|
protected void |
setPressed(boolean pressed)
Sets the pressed state of the toggle.
|
void |
toggle()
Changes the state of the toggle to the inverse of the current state.
|
void |
update()
Something has changed.
|
contains, isAdjustedToChild, setAdjustedToChild, setBoundsContent, setWidget, validateContent
add, addClassSelector, getAttribute, getChild, getChildrenCount, getChildrenElements, getParentElement, getStyle, hasClassSelector, isTransparent, mergeStyle, removeAllClassSelectors, removeClassSelector, removeInstanceStyle, render, renderContent, setBounds, setClassSelectors, setEnabled, updateStyle, updateStyleOnly, validate
getFocus, getFocusIndex, getNext, getWidget, getWidgetAt, getWidgets, getWidgetsCount, hideNotify, iterator, remove, removeAllWidgets, requestFocusFrom, showNotify
getAbsoluteX, getAbsoluteX, getAbsoluteY, getAbsoluteY, getEventHandler, getHeight, getPanel, getParent, getPreferredHeight, getPreferredWidth, getRelativeX, getRelativeY, getWidth, getX, getY, hasFocus, invalidate, isEnabled, isShown, isValid, isVisible, repaint, repaint, revalidate, revalidateSubTree, setEventHandler, setLocation, setPreferredSize, setSize, setVisible
public ToggleWrapper()
Events received by the toggle button are forwarded to the referent toggle.
public ToggleWrapper(ToggleModel toggle)
Events received by the toggle button are forwarded to the referent toggle.
toggle
- the referent toggle.java.lang.NullPointerException
- if the toggle is null
.public ToggleWrapper(ToggleModel toggle, java.lang.String group)
Events received by the toggle button are forwarded to the referent toggle.
The toggle is registered in the group with the given name.
toggle
- the referent toggle.group
- the name of the toggle group.java.lang.NullPointerException
- if a parameter is null
.public ToggleModel getToggle()
public void setGroup(@Nullable java.lang.String groupName)
For each name, a toggle group is created to group the toggles (only one toggle selected at a time).
groupName
- the name of the toggle group.ToggleGroup
public void addOnStateChangeListener(OnStateChangeListener listener)
listener
- the listener to add.java.lang.NullPointerException
- if the given listener is null
.public void removeOnStateChangeListener(OnStateChangeListener listener)
listener
- the listener to add.public void setChecked(boolean checked)
If the toggle is not enabled or is already in the given state, nothing change.
checked
- the new state of the toggle.public void toggle()
If the toggle is not enabled, nothing change.
public boolean isChecked()
true
if the toggle button is checked otherwise false
.public void gainFocus()
gainFocus
in class StyledComposite
public void lostFocus()
lostFocus
in class StyledComposite
public boolean isInState(State state)
Element
isInState
in interface Element
isInState
in class StyledComposite
state
- the state to check.true
if the element is in the given state, false
otherwise.protected void setPressed(boolean pressed)
pressed
- the new pressed state of the toggle.public void update()
GenericListener
update
in interface GenericListener
public boolean handleEvent(int event)
handleEvent
in interface ej.mwt.Renderable
handleEvent
in class ej.mwt.Composite
public void requestFocus()
requestFocus
in class ej.mwt.Composite
public boolean requestFocus(int direction) throws java.lang.IllegalArgumentException
requestFocus
in class ej.mwt.Composite
java.lang.IllegalArgumentException