On 2013-12-04 14:54, Leif Samuelsson wrote:
It seems to me that you could do this with a small class extending ToggleButton.
Add a couple of String properties and use a selection listener to switch the
main text value.

You wouldn't need to write any skin or behavior classes, Just define the look
in CSS and use -fx-label-padding to place the text on the background.

Or maybe just -fx-alignment will be enough.


On 2013-12-04 14:05, Pedro Duque Vieira wrote:
OK, sounds reasonable. Too bad about the code duplication that will need to
take place.

Thanks Jonathan and thanks for the link.


On Wed, Dec 4, 2013 at 9:39 PM, Jonathan Giles <jonathan.gi...@oracle.com>wrote:

It is likely significantly easier to simply roll your own control and
not try to coerce ButtonBase to support two labels.

For what it is worth, Paru and I talked about precisely this control at
JavaOne 2012, which you can watch on YouTube here:


-- Jonathan

On 5/12/2013 10:16 a.m., Pedro Duque Vieira wrote:

I'm trying to create a new control to be used by other developers. It is
know as "Toggle Switch".
You can see this control in android:
http://ankri.de/switch-button-for-android-2-3-gingerbread/ in iOS:
http://iosguides.net/ios-menus-comparison/ (search for "Toggle Switch")
on Windows 8:

"Step 2").

My approach was to subclass ButtonBase which is itself a subclass of
Labeled. The problem here is that Labeled only accepts one label but the
Toggle Switch needs two: one for the "on" state and another for the

Any ideas on how to best approach this problem?

Thanks in advance, regards,

Reply via email to