Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 644
Hai Zhang Avatar asked Nov 18 '15 17:11

Hai Zhang


1 Answers

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

like image 136
Collins Abitekaniza Avatar answered Nov 01 '22 03:11

Collins Abitekaniza