Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


shweta
JRadio Button
1 Answer(s)      4 years and 5 months 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

Advertisement
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");
f.getContentPane().setLayout(null);
JLabel lbl1 = new JLabel("Course");
JRadioButton c1,c2;
ButtonGroup radioGroup=new ButtonGroup();
c1=new JRadioButton("Semwise Course");
radioGroup.add(c1);
c2=new JRadioButton("Yearwise Course");
radioGroup.add(c2);
lbl1.setBounds(50,50,70,30);
c1.setBounds(110,50,200,30);
c2.setBounds(310,50,200,30);
f.add(lbl1);
f.add(c1);
f.add(c2);
f.setSize(500,500);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}

Thanks


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
Button  How to use image for button in JSF
Advertisements
button
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
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
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
radio button
radio button  On selecting a radio button, it should open a aspx page
html button
html button  when i click the submit button the entered data will be displayed below the submit button please help me
coding of button
coding of button  What is code of fetching the value of button in a textbox using javascript
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
create a button
create a button  i have created button inhtml but my jsp is not working,so can u guide 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
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>
on click button php
on click button php  Function in PHP for on click button
handling Button Event in iphone
handling Button Event in iphone  handling Button Event in iphone
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
create a button in html
create a button in html  How do I create a button which acts like a link
uitableviewcell delete button position
uitableviewcell delete button position  uitableviewcell delete button position - how can i set? Thanks in Advance
info button iphone example
info button iphone example  I'm looking for a simple info button example in iPhone XCode. Thanks
Create Button in CSS
Create Button in CSS  Can anyone help me to create a button in CSS HTML
facebook like button code
facebook like button code  How to create a facebook like button? can anyone share the code..?? Thanks in advance
how to use button in array
how to use button in array  plz tell me how to code for button in array
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
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
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
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
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
iphone button click event
iphone button click event  Hi, How to write iphone button click event? Thanks   Hi, Here the method declaration: -(IBAction) myMetod...{ NSLog(@"Button clicked"); } Thanks
button actions in struts
button actions in struts  in my jsp page i have two buttons add and sub.when i clicking the add button one action is performed and clicking the sub button another action is performed.how i will handle it using struts.i am using
navigation item back button
navigation item back button  I wants to add a navigationBar on the top of my UIWebView also a navigation item "back button". can anyone please explain how the back and refresh button works
jquery button click
jquery button click  jquery button click - I have created a button... to create a button event in JQuery. You can edit it as per your requirement. In Header...(){ alert("button clicked"); }); }); </script> JQuery HTML
browser back button
browser back button   hi...i created one page in JSF.that page had three form division.in first form one add button is there.if i click that button move to second form,then i click browser back button ,it moves on another page.so
Struts 2 Radio Button
radio buttons and I am using Struts2 tag.I want first rado button to be selected by default.But when i select the second radio button and hit on search button i want to retain the selection of that second radio button on search list
JSP Submit Button
JSP Submit Button  Sir, I have a JSP page with 2 Submit button, both calls doPost method of same servlet. If I click any submit button the text box value get refreshed and set to null or blank, that should not happen. Plz help
validation of radio button
validation of radio button  There are 3 radio button as A,B,W. there are another radio as 1,2,3.if we select W in first radio button then should select 2nd one(1,2,3).if we select A or B not need select any one from 1,2,3
Browser's back button
Browser's back button  how to redirect to a home page when browser's back button is pressed in jsp instead of displaying the previous page
Enable Browser's back button
Enable Browser's back button  how to redirect to a home page when browser's back button is pressed in jsp instead of displaying the previous page
Browser's back button
Browser's back button  how to redirect to a home page when browser's back button is pressed in jsp instead of displaying the previous page
radio button - Development process
radio button  hi, there is 2 radio button and five text box... but when i click on cr radio button and enter value in text box.it enter the msg but it again go to sr radio button   Hi friend, Plz give full
uinavigationcontroller back button action
uinavigationcontroller back button action  Hi, Tell me how to back... will display the back view on click of a button in my iPhone and iPad based application. Give me any code for uinavigationcontroller back button action method. Thanks
PushViewController back button
PushViewController back button  How can i hide the back button... it always show back button.   In your ViewDidLoad method just hide the navigation back button as given in the code. navigationItem.hidesBackButton = YES
iPhone Radio Button Example
iPhone Radio Button Example  Can you please suggest me how to create Radio button in my iPhone application. Actually, in my application i have two... click on that button it get selected and by default it should display unselected
Button in Flex
Button: A Button is usually in rectangular shape and it looks like it can be pressed, it could have a text, an icon, or both. A Button could be a normal button or toggle button. A normal button persists in deselected mode
uitableview edit done button
uitableview edit done button  How to add Edit / Done button in UITableView with an action on click?   UITableview Edit done Button To add " Edit / Done button " in UITableView add the given code in UIView Controller
image on submit button
image on submit button  i need to set an image on submit button. In javascript we can create a button like.. <a href="javascript:;" class="button">Sign up</a> But how will i do it from CSS?   The best way
jsp continuation button
jsp continuation button  i have 2 jsps, 1st jsp page with continue button and 2nd jsp with submit button.so how do i create a sessionvariable in order to submit the 2jspforms
button with rounded corner in java
button with rounded corner in java  Hi, I want to create a JButton with rounded corners in swings. I went through many programs but did not got the solutions. Thanks and regards, Vivek Birdi
Advertisements
 

 

 

DMCA.com