Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
Java
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

Radio Button In Java

                         

Introduction

In this section, you will learn how to create Radio Button on the frame. The java AWT , top-level window, are represent by the CheckBoxGroup.  A java program provides you CheckboxGroup. In this program, you will see how to create and show the Checkboxgroup component on the frame.

In this program a radio button is created that is an item that can be selected or deselected and displays that state to the user. Here we are creating a group of buttons in which you can select only one option at a time. Here, explanation for the procedure of inserting checkbox group on the Java AWT frame.

Program Description:

Here class named RedioButton, is used in the program for creating a checkboxgroup component. The CheckboxGroup class is  used to set the group together on the checkbox button. A check box group button in a CheckboxGroup can be in the "on" state at any time and pushing any button sets it's state to "on". Clicking any radio button that is in the "off" state turns it into the "on" state.

CheckBoxGroup():  This constructor is used to create a new instance of CheckboxGroup.

Here is the code of  this program:

import java.awt.*;
import java.awt.event.*;
  public class RadioButton{
  public static void main(String[] args) {
    Frame fm=new Frame("RedioButton Group");
    Label la=new Label("What is your choice:");
    fm.setLayout(new GridLayout(01));
    CheckboxGroup cg1=new CheckboxGroup();
    fm.add(la);
    fm.add(new Checkbox("MATH", cg1, true));
    fm.add(new Checkbox("PHYSICS", cg1, false));
    fm.add(new Checkbox("CHEMISTRY", cg1, false));
    fm.add(new Checkbox("ENGLISH", cg1, false));
    fm.setSize(250,200);
    fm.setVisible(true);
    fm.addWindowListener(new WindowAdapter(){
      public void windowClosing(WindowEvent we){
        System.exit(0);
      }
    });
  }
}

Output this program:  

Download this example.

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

1 comments so far (
post your own) View All Comments Latest 10 Comments:

Nice and simple! I just have a few questions about the radio buttons, when you have a regular button and radio button selected, how do you make it so that when you click the button, an event of some sort will happen because one of the radio buttons are selected.

And, not trying to be mean here but in
" Frame fm=new Frame("RedioButton Group");" you wrote "RedioButton" which should be "Radiobutton"

Posted by Joël on Thursday, 10.2.08 @ 18:18pm | #80845

Latest Searches:
dojo dialog for onCanc
index jstl
how to pass same varia
Photoshop Basics 3D Ba
Bubble Sort in java
input in java roman nu
Haspmap
array sum
Web Messenger in java
add delete javascrip
Unicast AND multicast
primitivedata ypes
tree set
java applet repetitive
Jframe Tutorials
struts 2 regular expre
round
webservice
delete ajax php
jta
how to read the data i
read excel file and di
annotation in java
export to excel in js
login page jasp
java code for circula
Xml parsing using serv
à¹??à¸??ั???à¹??à¸?à
Combattons la programm
factorial in java
character in javascrip
code for i create a ta
commands
in mysql how to store
carters as a pimp draw
IgnoreCase
String based programme
Creating the Subscript
filesclass,java
how to reload page aft
carters as a pimp
How to transfer Docume
struts spring
how to write in pdf us
Hibernate Min() Functi
extract
Aะà¸??ะàÂ
html:checkbox is check
paging and sorting wit
Generated servlet erro
java program to transp
java.io.*
how to retrieve data f
string to integer
Visual Basic Introduct
PrintWriter(System.out
<bean:define>
jsp Insert insert data
Logical OR operator
spring dao
ALSB
array in javascript
insert data in to mysq
Disable the web browse
uml examples
how to use the selecti
poi Tutorials
AES
Convert String to Bool
java program to check
connection bean
set new color in jsf
Linux Caixa M?????????
struts2 action element
servlet examples
example of one dimensi
Combattons la programm
how to create piechart
Constructor Inheritanc
linked list and GUI
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.