aman sagar
radio buttons
1 Answer(s)      9 months 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

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 Pages:
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
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
Radio Buttons
Java: Radio Buttons Radio buttons (javax.swing.JRadioButton.... The example below produced this image. A radio button group starts with all buttons... radio buttons, puts them in a grid layout on a panel, and puts a titled
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
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
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
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
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
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
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
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
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 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
Buttons
, ButtonGroup Radio buttons are a group of buttons that can have at most one... Java: Buttons There are many kinds of buttons, all derived from the AbstractButton class. ComponentsDescription JButton This is a standard button
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
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
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
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
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
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.. 
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 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
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
Get radio button value after submiting page
Get radio button value after submiting page  Radio buttons are dynamically generated.After selecting radio button & submitting the page...; }   You have to keep the name attribute same for all radio buttons
JSP Radio Button MySQL insert - JSP-Servlet
JSP Radio Button MySQL insert  Hi, I have an HTML form which has a couple of radio buttons for example (gender: male/female) and some check boxes... with the code to store radio button data and checkbox data to MySQL table. For example
Drop down and radio button value on edit action
mr.,mrs.,miss for payment type there are to radio buttons as by cash &...Drop down and radio button value on edit action  HI, I have... the value from dropdown and radio button.. But the problem goes with edit action
Radio Button In Java
Radio Button In Java       Introduction In this section, you will learn how to create Radio Button... a radio button is created that is an item that can be selected or deselected
when radio button is selected corresponding jsp page should open
when radio button is selected corresponding jsp page should open  how to write code in HTML & jsp, when we click on radio buttons...="form"> View Profile<input type="radio" value="view" name="radios" onclick
radio button
radio button  On selecting a radio button, it should open a aspx page
how to pass input from radio button to jsp page
how to pass input from radio button to jsp page  hi.. the code below here there are list of radio buttons here in jsp page when the values... have to keep the name attribute same for all radio buttons and you have to use
How to use radio button in jsp page
to selected radio buttons. First page in this example lets the user enter its name... How to use radio button in jsp page       This is detailed java code how to use radio
how to pass input from radio button to jsp page
how to pass input from radio button to jsp page  hi.. the code below here there are list of radio buttons here in jsp page when the values...; <input name="radiobutton" type="radio" value="radiobutton" />
how to pass input from radio button to jsp page
how to pass input from radio button to jsp page  hi.. the code below here there are list of radio buttons here in jsp page when the values...; <input name="radiobutton" type="radio" value="radiobutton" />
Dojo Radio Button
radio buttons in dojo. For creating radio button you need "...(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
Dojo Radio Button
radio buttons in dojo. For creating radio button you need "...(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
Tomahawk selectOneRadio tag
to create radio buttons on the page. It renders html input tag with type... of radio buttons. If this is set to "spread" value then it doesn't display html but provides feature to display radio buttons
add Buttons in JavaScript
add Buttons in JavaScript  How to add Buttons in JavaScript
uinavigationcontroller add multiple buttons
uinavigationcontroller add multiple buttons  How to add multiple buttons to the UINavigationController
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
HTML custom buttons
HTML custom buttons  How can I make a form with custom buttons
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
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
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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.