This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm trying to create a gui for a touch-screen environment. I'd like one of the controls to look like a ToggleButton - ie, a group of buttons - but duplicating specific behavior from a RadioButton (specifically, the inability to deselect buttons - I want one button selected at all times.) I don't want to use a RadioButton, because I want the pressable area to be as large as possible. Looking through the api, I don't see an easy way to enforce that functionality on a ToggleButton, and I'm not sure how I would reskin a RadioButton to look like a regular button. Does anyone have any advice?
You can add a ChangeListener to the ToggleGroup's selectedToggleProperty() that selects the oldValue if the newValue is null, wrapped in a Platform.runLater(...) to ensure all FX event code precedes the custom selection. This will give you a group of ToggleButtons with the desired behavior.
edit This is all you need:
Joined: Aug 22, 2012
Thanks a lot - that's exactly what I was looking for.