I'm implementing a toolbox-like pane, so user can only pick one tool at a time, and I switched from Button
to RadioButton
for its behavior.
But I found that RadioButton
uses its own skin with a dot, however I still want it to display like a normal Button
. I'm a beginner with JavaFX and FXML, so anyone know how can I accomplish this?
Finally I went with another way around. You can extend
ToggleButton
so that it behaves like aRadioButton
. This does not have the weird click effect of consuming mouse release.Then in FXML:
And it is done.
First Create a radio button, remove the
radio-button
style and then add thetoggle-button
style likeHope that solves your problem
Here is the style you can use to get rid of the dot
Documenting here; in case someone finds it useful.
You can use
ToggleButton
andToggleGroup
, but you have to create an extension ofToggleGroup
to keep the selected one selected. Here's an example.