Switch
class instead as it conforms to the latest platform looks and feels.public class OnOffSwitch extends Container implements ActionSource
The on/off switch is a checkbox of sort (although it derives container) that represents its state as a switch each of which has a short label associated with it. It has two types: Android and iOS. The types differ in the way that they are rendered. The Android type (the default) is just a button with a label that can be moved/dragged between the two states. The iOS version is more elaborate due to the look of that platform.
BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, CROSSHAIR_CURSOR, DEFAULT_CURSOR, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, E_RESIZE_CURSOR, HAND_CURSOR, LEFT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NW_RESIZE_CURSOR, RIGHT, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, TOP, W_RESIZE_CURSOR, WAIT_CURSOR
Constructor and Description |
---|
OnOffSwitch()
Deprecated.
Default constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addActionListener(ActionListener l)
Deprecated.
Adds a listener to the switch which will cause an event to dispatch on click
|
protected Dimension |
calcPreferredSize()
Deprecated.
Calculates the preferred size based on component content.
|
protected void |
deinitialize()
Deprecated.
Invoked to indicate that the component initialization is being reversed
since the component was detached from the container hierarchy.
|
Vector |
getActionListeners()
Deprecated.
use the version that returns a collection
|
Object |
getComponentState()
Deprecated.
Some components may optionally generate a state which can then be restored
using setCompnentState().
|
Collection |
getListeners()
Deprecated.
Returns a collection containing the action listeners for this button
|
String |
getOff()
Deprecated.
Label for the off mode
|
String |
getOn()
Deprecated.
Label for the on mode
|
String[] |
getPropertyNames()
Deprecated.
A component may expose mutable property names for a UI designer to manipulate, this
API is designed for usage internally by the GUI builder code
|
Class[] |
getPropertyTypes()
Deprecated.
Matches the property names method (see that method for further details).
|
Object |
getPropertyValue(String name)
Deprecated.
Returns the current value of the property name, this method is used by the GUI builder
|
Image |
getSwitchMaskImage()
Deprecated.
Gets the image that is used for the mask.
|
Image |
getSwitchOffImage()
Deprecated.
Gets the image that is used for the "Off" state of the switch.
|
Image |
getSwitchOnImage()
Deprecated.
Gets the image that is used for the "On" state of the switch.
|
protected void |
initComponent()
Deprecated.
Allows subclasses to bind functionality that relies on fully initialized and
"ready for action" component state
|
boolean |
isNoTextMode()
Deprecated.
iOS 7 changed the switch to not include any text
|
protected boolean |
isStickyDrag()
Deprecated.
Returns true if the component is interested in receiving drag/pointer release events even
after the gesture exceeded its boundaries.
|
boolean |
isValue()
Deprecated.
The value of the switch
|
void |
paint(Graphics g)
Deprecated.
This method paints the Component on the screen, it should be overriden
by subclasses to perform custom drawing or invoke the UI API's to let
the PLAF perform the rendering.
|
void |
pointerDragged(int x,
int y)
Deprecated.
If this Component is focused, the pointer dragged event
will call this method
|
void |
pointerPressed(int x,
int y)
Deprecated.
If this Component is focused, the pointer pressed event
will call this method
|
void |
pointerReleased(int x,
int y)
Deprecated.
If this Component is focused, the pointer released event
will call this method
|
void |
removeActionListener(ActionListener l)
Deprecated.
Removes the given action listener from the switch
|
protected void |
resetFocusable()
Deprecated.
Restores the state of the focusable flag to its default state
|
void |
setComponentState(Object state)
Deprecated.
If getComponentState returned a value the setter can update the value and restore
the prior state.
|
void |
setNoTextMode(boolean noTextMode)
Deprecated.
iOS 7 changed the switch to not include any text
|
void |
setOff(String off)
Deprecated.
Label for the off mode
|
void |
setOn(String on)
Deprecated.
Label for the on mode
|
String |
setPropertyValue(String name,
Object value)
Deprecated.
Sets a new value to the given property, returns an error message if failed
and null if successful.
|
void |
setSwitchMaskImage(Image switchMaskImage)
Deprecated.
Sets the image that should be used for the "On" state.
|
void |
setSwitchOffImage(Image switchOffImage)
Deprecated.
Sets the image that should be used for the "Off" state.
|
void |
setSwitchOnImage(Image switchOnImage)
Deprecated.
Sets the image that should be used for the "Off" state.
|
void |
setValue(boolean value)
Deprecated.
The value of the switch
|
add, add, add, add, add, add, addAll, addComponent, addComponent, addComponent, addComponent, animateHierarchy, animateHierarchyAndWait, animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout, animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait, animateUnlayout, animateUnlayoutAndWait, applyRTL, cancelRepaints, clearClientProperties, constrainHeightWhenScrollable, constrainWidthWhenScrollable, contains, createAnimateHierarchy, createAnimateHierarchyFade, createAnimateLayout, createAnimateLayoutFade, createAnimateLayoutFadeAndWait, createAnimateMotion, createAnimateUnlayout, createReplaceTransition, dragInitiated, drop, encloseIn, encloseIn, findDropTargetAt, findFirstFocusable, fireClicked, flushReplace, forceRevalidate, getBottomGap, getChildrenAsList, getClosestComponentTo, getComponentAt, getComponentAt, getComponentCount, getComponentIndex, getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent, getLeadParent, getResponderAt, getSafeAreaRoot, getScrollIncrement, getSideGap, getUIManager, initLaf, invalidate, isEnabled, isSafeArea, isSafeAreaRoot, isScrollableX, isScrollableY, isSelectableInteraction, isSurface, iterator, iterator, keyPressed, keyReleased, layoutContainer, morph, morphAndWait, paintBackground, paintBorderBackground, paintComponentBackground, paintGlass, paramString, refreshTheme, removeAll, removeComponent, replace, replace, replaceAndWait, replaceAndWait, replaceAndWait, revalidate, revalidateLater, revalidateWithAnimationSafety, scrollComponentToVisible, setCellRenderer, setEnabled, setLayout, setLeadComponent, setSafeArea, setSafeAreaRoot, setScrollable, setScrollableX, setScrollableY, setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout, setUIManager, updateTabIndices
addDragFinishedListener, addDragOverListener, addDropListener, addFocusListener, addLongPressListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, addStateChangeListener, animate, bindProperty, blocksSideSwipe, calcScrollSize, contains, containsOrOwns, createStyleAnimation, deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver, drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBorder, getBoundPropertyValue, getBounds, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getCursor, getDefaultDragTransparency, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getDragTransparency, getEditingDelegate, getHeight, getInlineAllStyles, getInlineDisabledStyles, getInlinePressedStyles, getInlineSelectedStyles, getInlineStylesTheme, getInlineUnselectedStyles, getInnerHeight, getInnerPreferredH, getInnerPreferredW, getInnerWidth, getInnerX, getInnerY, getLabelForComponent, getName, getNativeOverlay, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getOuterHeight, getOuterPreferredH, getOuterPreferredW, getOuterWidth, getOuterX, getOuterY, getOwner, getParent, getPreferredH, getPreferredSize, getPreferredSizeStr, getPreferredTabIndex, getPreferredW, getPressedStyle, getPropertyTypeNames, getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle, getTabIndex, getTensileLength, getTextSelectionSupport, getTooltip, getUIID, getUnselectedStyle, getVisibleBounds, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFixedPreferredSize, hasFocus, hideNativeOverlay, initCustomStyle, initDisabledStyle, initPressedStyle, initSelectedStyle, initUnselectedStyle, installDefaultPainter, isAlwaysTensile, isBlockLead, isCellRenderer, isChildOf, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEditable, isEditing, isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHidden, isHideInLandscape, isHideInPortrait, isIgnorePointerEvents, isInClippingRegion, isInitialized, isOpaque, isOwnedBy, isPinchBlocksDragAndDrop, isRippleEffect, isRTL, isScrollable, isScrollVisible, isSetCursorSupported, isSmoothScrolling, isSnapToGrid, isTactileTouch, isTactileTouch, isTensileDragEnabled, isTraversable, isVisible, keyRepeated, laidOut, longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackgrounds, paintBorder, paintComponent, paintComponent, paintIntersectingComponentsAbove, paintLock, paintLockRelease, paintRippleOverlay, paintScrollbars, paintScrollbarX, paintScrollbarY, paintShadows, parsePreferredSize, pinch, pinch, pinchReleased, pointerDragged, pointerHover, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased, putClientProperty, refreshTheme, refreshTheme, remove, removeDragFinishedListener, removeDragOverListener, removeDropListener, removeFocusListener, removeLongPressListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, removeStateChangeListener, repaint, repaint, requestFocus, respondsToPointerEvents, scrollRectToVisible, scrollRectToVisible, setAlwaysTensile, setBlockLead, setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty, setCursor, setDefaultDragTransparency, setDirtyRegion, setDisabledStyle, setDraggable, setDragTransparency, setDropTarget, setEditingDelegate, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden, setHideInLandscape, setHideInPortrait, setIgnorePointerEvents, setInitialized, setInlineAllStyles, setInlineDisabledStyles, setInlinePressedStyles, setInlineSelectedStyles, setInlineStylesTheme, setInlineUnselectedStyles, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setOpaque, setOwner, setPinchBlocksDragAndDrop, setPreferredH, setPreferredSize, setPreferredSizeStr, setPreferredTabIndex, setPreferredW, setPressedStyle, setRippleEffect, setRTL, setSameHeight, setSameSize, setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid, setTabIndex, setTactileTouch, setTensileDragEnabled, setTensileLength, setTooltip, setTraversable, setUIID, setUIID, setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, shouldRenderComponentSelection, showNativeOverlay, startEditingAsync, stopEditing, stripMarginAndPadding, styleChanged, toImage, toString, unbindProperty, updateNativeOverlay, visibleBoundsContains
protected Dimension calcPreferredSize()
calcPreferredSize
in class Container
protected void resetFocusable()
resetFocusable
in class Component
protected boolean isStickyDrag()
isStickyDrag
in class Component
public void addActionListener(ActionListener l)
addActionListener
in interface ActionSource
l
- implementation of the action listener interfacepublic void removeActionListener(ActionListener l)
removeActionListener
in interface ActionSource
l
- implementation of the action listener interfacepublic Vector getActionListeners()
public Collection getListeners()
public void paint(Graphics g)
protected void initComponent()
initComponent
in class Component
protected void deinitialize()
deinitialize
in class Component
public void pointerPressed(int x, int y)
pointerPressed
in class Container
x
- the pointer x coordinatey
- the pointer y coordinatepublic void pointerDragged(int x, int y)
pointerDragged
in class Component
x
- the pointer x coordinatey
- the pointer y coordinatepublic void pointerReleased(int x, int y)
pointerReleased
in class Component
x
- the pointer x coordinatey
- the pointer y coordinatepublic String getOn()
public void setOn(String on)
on
- the on to setpublic String getOff()
public void setOff(String off)
off
- the off to setpublic boolean isValue()
public void setValue(boolean value)
value
- the value to setpublic String[] getPropertyNames()
getPropertyNames
in class Component
public Object getComponentState()
getComponentState
in class Component
public void setComponentState(Object state)
setComponentState
in class Component
state
- the non-null statepublic Class[] getPropertyTypes()
getPropertyTypes
in class Component
public Object getPropertyValue(String name)
getPropertyValue
in class Component
name
- the name of the propertypublic String setPropertyValue(String name, Object value)
setPropertyValue
in class Component
name
- the name of the propertyvalue
- new value for the propertypublic boolean isNoTextMode()
public void setNoTextMode(boolean noTextMode)
noTextMode
- the noTextMode to setpublic Image getSwitchOnImage()
setSwitchOnImage(com.codename1.ui.Image)
method, then this will return null.setSwitchOnImage(com.codename1.ui.Image)
,
getSwitchOffImage()
,
getSwitchMaskImage()
public void setSwitchOnImage(Image switchOnImage)
Note: If the "onOffIOSModeBool" theme constant is false and you set this image, you must also
set the "Off" image with setSwitchOffImage(com.codename1.ui.Image)
and the
"Mask" image with setSwitchMaskImage(com.codename1.ui.Image)
.
switchOnImage
- the switchOnImage to setgetSwitchOnImage()
,
setSwitchMaskImage(com.codename1.ui.Image)
,
setSwitchOffImage(com.codename1.ui.Image)
public Image getSwitchOffImage()
setSwitchOffImage(com.codename1.ui.Image)
method, then this will return null.setSwitchOffImage(com.codename1.ui.Image)
,
getSwitchOnImage()
,
getSwitchMaskImage()
public void setSwitchOffImage(Image switchOffImage)
Note: If the "onOffIOSModeBool" theme constant is false and you set this image, you must also
set the "On" image with setSwitchOnImage(com.codename1.ui.Image)
and the
"Mask" image with setSwitchMaskImage(com.codename1.ui.Image)
.
switchOffImage
- the switchOffImage to setgetSwitchOffImage()
,
setSwitchMaskImage(com.codename1.ui.Image)
,
setSwitchOnImage(com.codename1.ui.Image)
public Image getSwitchMaskImage()
This image will generally consist of an opaque border/frame with a transparent center such that the "on" and "off" images can be painted inside the transparent part, and anything that is outside that center will be painted over by the frame, or clipped.
setSwitchMaskImage(com.codename1.ui.Image)
getSwitchOffImage()
,
getSwitchOffImage()
,
setSwitchOnImage(com.codename1.ui.Image)
,
getSwitchMaskImage()
,
setSwitchMaskImage(com.codename1.ui.Image)
public void setSwitchMaskImage(Image switchMaskImage)
Note: If the "onOffIOSModeBool" is false and you set this mask, you must also
set the "On" image with setSwitchOnImage(com.codename1.ui.Image)
and the
"Off" image with setSwitchOffImage(com.codename1.ui.Image)
.
switchMaskImage
- the switchMaskImage image to set as the mask for the on-off
switch.