RadioButton use in JavaFX – Part #3 | Processing Events for RadioButtons | Tutorial for Beginners

In this session, we will discuss the radio button control implementation in our application. A Radio button has only two-state. It can be either selected or deselected. 

 
– Creating Radio Button from code only. (when we are not using FXML) ======================================================= 
//A radio button with an empty string for its label 
RadioButton rb1 = new RadioButton(); 
 
//Setting a text label 
rb1.setText(“Home”); 
 
//A radio button with the specified label 
RadioButton rb2 = new RadioButton(“Calendar”); 
 
– Creating a Graphical Radio button by using an image — (with FXML ) ======================================================== 
Image image = new Image(getClass().getResourceAsStream(“sample.png”)); 
RadioButton rb = new RadioButton(“Agree”); 
rb.setGraphic(new ImageView(image));
 
Please watch this video tutorial for a clear understanding of detailed implementation.
 
If you find this tutorial useful for you, Please like this tutorial and Subscribe my YouTube channel to learn more.
 
 

Leave a Comment