A Toggle Switch is a control that is very popular nowadays, especially on touch based devices. You can see it in Android:
In iOS (6 and 7):
And in Windows 8:
Functionally it works just like a check-box but for touch devices it has one big advantage: when your finger is over the touch device it won’t obscure the control and so you can see an instant feedback when you press it. The disadvantage is obviously that this control takes up more space.
My implementation of the Toggle Switch allows you to change the text for the on and off state that appears right next to the toggle switch. You can also style the control using just CSS. It comes with a CSS implementation that gives it a metro look.
Below you can see a live demonstration of the control, in a light and a dark theme.
You can grab the control and the accompanying metro style CSS by going to the jfxtras repository.
Currently it’s still not possible to style the Toggle Switch to look like the Android toggle switch using just CSS because it’s not possible to specify that the on and off text should appear inside the control and not outside as in the case of Metro. I’d also like to add the possibility to turn the animation on or off through CSS.
JavaFX links of the week, July 13 // JavaFX News, Demos and Insight // FX Experience
Java desktop links of the week, July 13 « Jonathan Giles
“Currently it’s still not possible to style the Toggle Switch to look like the Android toggle switch using just CSS because”…
Not sure if you know it but with Java 8 it is now remarkably simple to add your own styleable properties to a control. So you could have boolean styleable properties to have the text inside or outside, or to enable/disable animation.
Yes i know. Thanks
Am I missing something here? the ToggleSwitch in the repository is just a restyled ToggleButton
No its not. its a class of its own. including a css file.
ToggleSwitch control revisited – Pixel Duke
where is sorce code ?