Example : How to make single selection of radio button using property window.  

- First of all create all the radio buttons on jFrame1 - Now click and drag 'Button Groups' on the 
  jFrame1 from swing controls of Palette window (Button Groups does not appear on the jFrame1) - Now, 
  select single radio button on jFrame1 - Open 'Property window' - Select'Button Group' - 
  Choose button Group name (say 'buttonGroup1')from the 'none' downlist - Repeat the process to 
  select same buttongroup for rest radio button one by one -Run the program and check the selection 
  of radio button.

Example : How to make single selection of radio button using codes.  

import javax.swing.ButtonGroup;

 public class UserRegistrion extends javax.swing.JFrame {
    ButtonGroup Bg= new ButtonGroup();     //Global declaration

    public UserRegistrion() {
        initComponents();
        
           Bg.add(jRadioButton1Male);
           Bg.add(jRadioButton2Female);
           Bg.add(jRadioButton3Other);
    }

}

Loading

Categories: Java Project

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.