❮ Previous Next ❯

JRadioButton

The JButton class which extends AbstractButton class that is used to create a button. JButton supports ActionEvent, that means when a button is clicked, an ActionEvent is generated.

Basically radio button is a group of related button from which one can be selected only. JRadioButton class is used to create a radio button in Frames. JRadioButton having following constructor, JRadioButton(String s)

JRadioButton Example

importjava.awt.event.*;
importjava.awt.*;
public class JRadioButtonDemo extends JFrame
{
publicJRadioButtonDemo() 
 {
JRadioButtonjcb = new JRadioButton("A");	//creating JRadioButton.  
add(jcb);					//adding JRadioButton to frame. 
jcb = new JRadioButton("B");			//creating JRadioButton. 
add(jcb);					//adding JRadioButton to frame. 
jcb = new JRadioButton("C");			//creating JRadioButton.  
add(jcb);					//adding JRadioButton to frame. 
jcb = new JRadioButton("none");
add(jcb);
setLayout(new FlowLayout());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300, 300);
setVisible(true);
 }
public static void main(String[] args)
 {
newJRadioButtonDemo();
 }
}

Output

pic

❮ Previous Next ❯



  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved