JRadio Button



Share on Google+Share on Google+

JRadio Button
1 Answer(s)      7 years ago
Posted in : Java Beginners
I have added two RadioButtons in Swing Appliction ,I want to select only one JRadioButton ,How I can Select it?
plz Help Me
View Answers

April 8, 2010 at 10:18 AM

Hi Friend,

Use ButtonGroup class.

Try the following code:

import java.sql.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class SwingFrame{

public static void main(String[] args) throws Exception{
SwingFrame sf=new SwingFrame();
public SwingFrame(){
JFrame f = new JFrame("Frame in Java Swing");
JLabel lbl1 = new JLabel("Course");
JRadioButton c1,c2;
ButtonGroup radioGroup=new ButtonGroup();
c1=new JRadioButton("Semwise Course");
c2=new JRadioButton("Yearwise Course");



Related Tutorials/Questions & Answers:
JRadio Button - Java Beginners
JRadio Button  I have added two RadioButtons in Swing Appliction ,I want to select only one JRadioButton ,How I can Select it? plz Help Me   Hi Friend, Use ButtonGroup class. Try the following code: import
Button  How to use image for button in JSF
button  can i give multiple commands on click of a button? if yes how can i do that?? multiple commands can we retriving dat from database, capturing data, moving to next page.. etc
button  can i give multiple commands on click of a button? if yes how can i do that?? multiple commands can be retriving dat from database, capturing data, moving to next page.. etc
wnidows button
wnidows button   How to handle windows back and forward button in struts applications, without using java script
radio button
radio button  On selecting a radio button, it should open a aspx page
Style in button
Style in button  Hi.... How can I set the button width with fx:style... of the button will not set by the style because it is the property of the button not the style property of the button. Thanks
html button
html button  when i click the submit button the entered data will be displayed below the submit button please help me
Back button
Back button  how to redirect to a home page when a back button is pressed in jsp instead of displaying the previous page
create a button
create a button  i have created button inhtml but my jsp is not working,so can u guide me
flogin button
flogin button  how to pass redirctt url for flogin button...and to retrieve parameters that are passed in that url..to store in our database
coding of button
coding of button  What is code of fetching the value of button in a textbox using javascript
uikeyboard done button/return button
uikeyboard done button/return button  Hi everyone!!! Just worried about ..how to return the UIKeyboard on done or return button click in my iPhone... to return the uikeyboard on done button click. Do not forget to call <
button tag
button tag  how do i change button color to black. meant to say i want black button with white text on it   Hi Friend, Try the following... Message: <input type="text" id="msg"><br> <input type="button" value
button in java
button in java  how can i compare names of two buttons after...) { System.out.println("button clicked"); } } Thanks   Hi.... i want to keep the labels on the button same yet identify them individually
submit button
submit button  <p>hi I am trying to insert record in database using hibernate in JSP(Netbeans). When I click insert button it should go to insert.java class but fails to go.</p> <ul> <li><p>
handling Button Event in iphone
handling Button Event in iphone  handling Button Event in iphone
on click button php
on click button php  Function in PHP for on click button
HTML Button onclick get ID of Button
HTML Button onclick get ID of Button  How i can get the ID of HTML Button on click?? I wanted to do it using JavaScript function. Thanks
how to use button in array
how to use button in array  plz tell me how to code for button in array
facebook like button code
facebook like button code  How to create a facebook like button? can anyone share the code..?? Thanks in advance
Create Button in CSS
Create Button in CSS  Can anyone help me to create a button in CSS HTML
info button iphone example
info button iphone example  I'm looking for a simple info button example in iPhone XCode. Thanks
uitableviewcell delete button position
uitableviewcell delete button position  uitableviewcell delete button position - how can i set? Thanks in Advance
create a button in html
create a button in html  How do I create a button which acts like a link
Button in Dojo - Framework
Button in Dojo  I want to create button in Dojo, new to dojo  Dojo - creating a button, lets say hello world button using DOJODojo Button Example http://www.javajazzup.com/issue9/page40.shtmlDojo Tutorial Resourceshttp
Swing Button Example
Swing Button Example  Hi, How to create an example of Swing button in Java? Thanks   Hi, Check the example at How to Create Button on Frame?. Thanks
passing values on button click
passing values on button click  Please help me to solve this issue.I want to pass a value assigned to button to another view upon button click in xcode
next button in servlet
next button in servlet  i want to add next,previous button to get next record in my servlet. can you explain the logic to do
How to get Button Id ?
How to get Button Id ?  How to get Button ID instead of its value in Servlet. (I am not using jsp right now
facebook login button html
facebook login button html  facebook login button html i have a facebook login button code ..but not sure how to use it. Can any one please explain? Here is the facebook login button code in html <fb:login-button
Java Spring Hibernate Struts Training ClassNotFoundException HttpRequestInterceptor java.lang.noclassdeffounderror: org/apache/http/httprequest noclassdeffounderror: org/apache/http/client/methods/httpurirequest java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient How do I resolve this Java Class not found exception? httpclient java.lang.NoClassDefFoundError Apache Commons ioutils maven dependency Read/Convert an inputStream to a String What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history Best Reasons to learn Java


Advertisement null