Is there a standard implementation or library that provides a GUI toggle switch in Swing? I know Swing provides a toggle button, but the UX leaves a bit to be desired. I'm looking for this:
Also, is there a canonical term for this type of control? The Apple HIG refer to it as a UISwitch. I also tried searching for "toggle switch", but I didn't have much luck. (Plenty of JavaScript results, but nothing native.)
We are using the following APIs. JToggleButton() − To create a toggle button. JToggleButton. isSelected() − To check if toggle button is currently in pressed state or not.
A toggle button allows the user to change a setting between two states. You can add a basic toggle button to your layout with the ToggleButton object.
Majority of existing GUI java codebases are Swing and likely will stay that way until the codebase rots and nobody maintains it anymore. Majority of new GUI java codebases are using JavaFX , which is the Swing replacement in Java8 and is part of the standard java library now.
Swing is a GUI widget toolkit for Java. It is part of Oracle's Java Foundation Classes (JFC) – an API for providing a graphical user interface (GUI) for Java programs.
You might mimic it by using two icons to represent on & off, then set those to a JToggleButton
.
As an aside, users want to see logical and consistent GUIs that represent the 'path of least surprise', it's developers that think users want a 'beautiful, clever' GUI (and that they can design one). Why on earth would they want such a control over a standard toggle-button?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With