Dreaming in Code Dreaming in Code - 23 days ago 10
Java Question

How to make a RadioButton look like regular Button in JavaFX

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?

Answer

First Create a radio button, remove the radio-button style and then add the toggle-button style like

RadioButton radioButton=new RadioButton("Radio");
radioButton.getStyleClass().remove("radio-button");
radioButton.getStyleClass().add("toggle-button");

Hope that solves your problem