Overview
JSwitch is a toggle switch component that extends JCheckBox and provides an iOS-style switch appearance. It inherits all properties and methods from JCheckBox.
Constructors
JSwitch()
Creates a switch with no text label.JSwitch(String text)
Creates a switch with the specified text label.The text label to display next to the switch
Inherited Properties
SinceJSwitch extends JCheckBox, it inherits all properties:
colorStyle
The color style of the switch
PRIMARY- Primary theme colorSUCCESS- Success/green colorDANGER- Danger/red colorWARNING- Warning/yellow colorINFO- Info/blue colorDARK- Dark colorSECONDARY- Secondary theme color
size
The size of the switch
SMALL- Small switchDEFAULT- Default/medium switchLARGE- Large switch
Inherited Methods
All methods fromJCheckBox are available:
setColorStyle(CheckBoxStyle style)
Sets the color style of the switch.The color style to apply
getColorStyle()
Returns the current color style.The current color style of the switch
colorStyleProperty()
Returns the color style property for binding.The observable property for color style
setSize(CheckBoxSize size)
Sets the size of the switch.The size to apply
getSize()
Returns the current size.The current size of the switch
sizeProperty()
Returns the size property for binding.The observable property for size
Example Usage
CSS Style Classes
The component applies the following style classes:j-switch- Switch-specific style classj-checkbox- Inherited base style classcheckbox-primary,checkbox-success, etc. - Inherited color style classescheckbox-sm,checkbox-md,checkbox-lg- Inherited size style classes
Design Notes
JSwitch provides an iOS-style toggle switch appearance while maintaining all the functionality of a checkbox. The visual design differentiates it from a standard checkbox with rounded track and animated toggle behavior.