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




Have Programming Question? Ask it here!
 
 
 


aman sagar
radio buttons
1 Answer(s)      2 years ago
Posted in : Java Beginners


write a program to create an applet button which has a list of radio buttons with titles of various colours.set the background colour of the applet to the selected colour


Advertisement
View Answers

August 22, 2012 at 2:58 PM


Here is an applet example which has a list of radio buttons with titles of various colors and a button. The given code sets the background color of applet according to the radio button selected by the user.

import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class GetSelectedRadioButton extends Applet implements ItemListener,ActionListener{

        CheckboxGroup gp = null;

        public void init(){
                gp = new CheckboxGroup();
                Checkbox c1 = new Checkbox("RED", gp, true);
                Checkbox c2 = new Checkbox("GREEN", gp, false);
                Checkbox c3 = new Checkbox("BLUE", gp, false);
                Button b=new Button("OK");              
                add(c1);
                add(c2);
                add(c3);
                add(b);

                c1.addItemListener(this);
                c2.addItemListener(this);
                c3.addItemListener(this);
                b.addActionListener(this);
        }

        public void itemStateChanged(ItemEvent ie) {
                repaint();
        }

        public void actionPerformed(ActionEvent e){

                Checkbox chk = gp.getSelectedCheckbox();
                if(chk.getLabel().equals("RED")){
                    setBackground(Color.RED);
                }
                if(chk.getLabel().equals("GREEN")){
                    setBackground(Color.GREEN);
                }
                if(chk.getLabel().equals("BLUE")){
                    setBackground(Color.BLUE);
                }
          }
}

Now to call the above applet, you need to create an html code. Here it is:

<HTML>
<BODY>
<APPLET CODE ="GetSelectedRadioButton.class" WIDTH="800" HEIGHT="500"></APPLET>
</BODY>
</HTML>


Related Tutorials/Questions & Answers:
radio buttons
radio buttons  write a program to create an applet button which has a list of radio buttons with titles of various colours.set the background colour... has a list of radio buttons with titles of various colors and a button
Radio Buttons - Java Beginners
Radio Buttons  Hello Sir, How to create the code for the password... the radion buttons in display the same page in jsp.I need only how to make the question and answer page using the radio buttons.please help me to solve
Advertisements
Radio Buttons in Jsp - JSP-Servlet
Radio Buttons in Jsp  Hi, i have a page in which there are lot of radio buttons [IMG]http://i38.tinypic.com/jzi6vc.jpg[/IMG] see the above picture..." depending on the value in the String radio button has to be checked. How to do
Radio Buttons in DB Very Urgent - JSP-Servlet
Radio Buttons in DB Very Urgent  Respected Sir/Madam, I am... in the database.Here I need Radio Buttons added dynamically for each Row. When I click the corresponding Radio Button and Submit,The Emp ID and Emp Name must
Tab sequence problem with Radio buttons - JSP-Servlet
Tab sequence problem with Radio buttons  Hi, I have membership type in application as 1 year(radio button) 2 year(radio button) 4 year(radio button) courier delivery courier(radio button) currently tab sequence going
prog. using radio buttons for simple calculator
prog. using radio buttons for simple calculator  import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; class Calculator extends JFrame { private final Font BIGGER_FONT = new Font
prog. using radio buttons for simple calculator
prog. using radio buttons for simple calculator  import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; class Calculator extends JFrame { private final Font BIGGER_FONT = new Font
Java radio buttons and button groups two values
Java radio buttons and button groups two values  hi i have a problem. i have a system to input data from a jform to a mysql database. i have made all of it except the gender radiobuttons. how do i do this? i need when register
Java radio buttons and button groups two values
Java radio buttons and button groups two values  hi i have a problem. i have a system to input data from a jform to a mysql database. i have made all of it except the gender radiobuttons. how do i do this? i need when register
WRITE A CODE IN STRUTS ACTION CLASS FOR CHECK BOXES AND RADIO BUTTONS - Struts
for check boxes and radio buttons and for submit buttons. i have a jsp page which contains check boxes,radio buttons.and when i click submit button the related...WRITE A CODE IN STRUTS ACTION CLASS FOR CHECK BOXES AND RADIO BUTTONS 
inserting data from radio buttons to database - JSP-Servlet
inserting data from radio buttons to database  hi, i am getting error in my code of feedback form. once i finished selecting all the radio buttons and when i click on delete button. it points to the answer.jsp. answer.jsp
inserting data from radio buttons to database - JSP-Servlet
inserting data from radio buttons to database  hi, my problem... of radio buttons. the feedback.jsp should look like same as follows: Please... as per his choice. when user completes all the selection of radio buttons and he
Display Label and radio buttons runtime with respect to DB values
Display Label and radio buttons runtime with respect to DB values  Requirement: I am getting alertCondition,Y,W values from DB the the cooresponding fields like the following: JLbel- alertCondition-"alert1","Alert2" JradioButton
inserting data from radio buttons to database-ERROR - JSP-Servlet
inserting data from radio buttons to database-ERROR  hi, i have already changed the option field of table question. the code which you give me has the option field as options. but it is option in the table,so i changed
Radio buttons in html
Radio buttons in html Here is an example of radio button in html.In this example we have display two radio button Male and Female. The user select only one.... Example radioButton.html <html> <head><title>Radio button
Radio Buttons in HTML
Radio Buttons in HTML     ... The Tutorial illustrates an example from Radio Buttons in HTML.In this Tutorial, the code explain to create a Radio Buttons. The code enables a user to select one
Buttons
Buttons  I have created a web page with radio button group with two radio buttons for accepting the home appliances categories,Kitchen appliances... radio button is selected.Which event listener do I need to implement for this task
Create Radio Buttons in SWT
Create Radio Buttons in SWT       This section illustrates you how to create radio button. In SWT, the style RADIO defined in the Button class allows to create radio button. We
need help for writting code in struts action class for check boxes and radio buttons - Struts
people.iwould like to write code in struts action class for check boxes and radio buttons and for submit buttons. i have a jsp page which contains check boxes,radio...need help for writting code in struts action class for check boxes and radio
how to access radio buttons selected in a servlet??...iam unable to retrieve values...it is returning NULL
how to access radio buttons selected in a servlet??...iam unable to retrieve...; <p>4.what is currency of USA?</p> <input type="radio...; <input type="radio" name="d" onclick="getAnswer('b')" value="b "/>pound
how to access radio buttons selected in a servlet??...iam unable to retrieve values...it is returning NULL
how to access radio buttons selected in a servlet??...iam unable to retrieve...; <p>4.what is currency of USA?</p> <input type="radio...; <input type="radio" name="d" onclick="getAnswer('b')" value="b "/>pound
Dojo Radio Button
; In this section, you will learn how to create radio buttons in dojo...(dijit.form.CheckBox) for RadioButtons to work. [Radio buttons are used when there is a list....] Radio Buttons are the same as html but dojo provides more controls and styling
Selecting a Radio Button component in Java
shows five radio buttons with labeled by "First", "Second"...-different radio buttons. Following are the screen shots for the result... Selecting a Radio Button component in Java   
radio nuttpn
radio nuttpn  i have created a html page containing 20 multiple choice questions when i clicl the options which are radio buttons. I have tp retroebe it in a jsp pahe ansabe it in mysql database...further i have to match
radio button
radio button  On selecting a radio button, it should open a aspx page
Struts 2 Radio Button
Struts 2 Radio Button  I have a search functionlaity where i have two 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
add Buttons in JavaScript
add Buttons in JavaScript  How to add Buttons in JavaScript
Radio button in JSP - JSP-Servlet
Radio button in JSP  Hi! In my page I have two radio buttons. If i select first radio button. one text field has to be displayed.... If i select second radio button. text field has to be disappeared. pls.... help me.. 
dependent radio button
dependent radio button  Hi. I have 4 radio buttons say all,chocolate,cookie,icecream. If I select all the other 3 should not able to be selected... of the Radio Button is to select only one option at a time. So you don't need
uinavigationcontroller add multiple buttons
uinavigationcontroller add multiple buttons  How to add multiple buttons to the UINavigationController
HTML custom buttons
HTML custom buttons  How can I make a form with custom buttons
radio button - Development process
radio button  hello,i want to creat two radio button.out of which only one can be selected.and can show the contain of selected radio box   Hi friend, Code to solve the problem : My Page Radio 11
URL CODE OF BUTTONS
URL CODE OF BUTTONS   how to create a button tag, i need a details for creating a button tag with url code
Radio Button in HTML
of radio buttons. It is necessary that the name remains the same within a group... to remember while using Radio Button: All Radio Buttons within a group must share the same name Value of the Radio Buttons within a group must be different
access into radio button
access into radio button  access the four fields of database called access,access file and stored in radio button.please help
labels,textfields,buttons
labels,textfields,buttons  how to set the labels,textfields,buttons at certain positions such that we can add them without layout managers? my program is to design a login page with image and these labels at exact positions
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
RADIO FROM JSP TO ACTION.
RADIO FROM JSP TO ACTION.  Hi frds, how to get the selected multiple radio button values from jsp to action
creating dynamic buttons in iphone
creating dynamic buttons in iphone  i Have a UIView and i wanted to create a multiple buttons to that should come on view load. It will be great if that can be removed after sometime or required time.   -(void
buttons in netbeans,java
buttons in netbeans,java  respected sir, i would like to known how to make coding on a button while working on netbeans, so that a new window will open after clicking on that button? thank you   import java.awt.
java buttons - Swing AWT
java buttons  There are 3 buttons in a window....A,B,C.If a user clicks button A ,a clue is given to him leading to button B.After the user clicks both A and B,he clicks C which is a submit button.After this both A and B should
more Submit buttons in the same form
more Submit buttons in the same form  Can I have two or more Submit buttons in the same form
Handling multiple buttons in HTML Form
Handling multiple buttons in HTML Form  How to handle Handling multiple buttons in HTML Form
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
how to get radio value
how to get radio value    how to retrive the option value and insert the next table pls give example
Radio button validation using jsp - JSP-Servlet
a value for radio Buttons) then it will return to same jsp page with the given...Radio button validation using jsp  I had one jsp Page and servlet. I did my validations in servlet for my jsp page which contains the radio
Query on radio button
Query on radio button  I am having a multiple row in jsp page.They are dynamically coming. For each row there is one radio button. I want to select one row only, i.e I want to fetch the value of row and on submitting the page
java radio button and exception
java radio button and exception  Dear Sir/Madam, I have problem with my addBagelRadioButton and addCheeseRadioButton. There should be only 1 radio button can be selected, but somehow 2 can be selected the same time. Also, I
Radio button Validation
Radio button Validation  Hi.. How to validate radio button in java?if the radio button is not selected an error message should be given... Please...()==false)){ JOptionPane.showMessageDialog(null,"Please select radio button
How to play radio station on iPhone
How to play radio station on iPhone  how to play radio station on iphone
 

 

 

DMCA.com