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 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 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 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 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 What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code


Advertisement null