| Author |
ToggleButton vs RadioButton
|
Matt Dalen
Greenhorn
Joined: Aug 22, 2012
Posts: 9
|
|
Hey, all,
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?
Thanks.
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4163
|
|
I don't see an easy way to enforce that functionality on a ToggleButton
Have you checked out the tutorial? Using JavaFX UI Controls - ToggleButton
edit Oh ok, I see you don't want to allow deselection of all buttons.
|
luck, db
There are no new questions, but there may be new answers.
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4163
|
|
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:
|
 |
Matt Dalen
Greenhorn
Joined: Aug 22, 2012
Posts: 9
|
|
|
Thanks a lot - that's exactly what I was looking for.
|
 |
 |
|
|
subject: ToggleButton vs RadioButton
|
|
|