radio buttons

Ads
 

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 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>

Ads









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
3 RADIO BUTTONS
3 RADIO BUTTONS  3 RADIO BUTTONS USING ALSO ONE RADIO CLICKING HOW TO PROCESS OF NEXTPAGE
Advertisements
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
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
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
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
ModuleNotFoundError: No module named 'buttons'
ModuleNotFoundError: No module named 'buttons'  Hi, My Python... 'buttons' How to remove the ModuleNotFoundError: No module named 'buttons... to install padas library. You can install buttons python with following command
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
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
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
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
ModuleNotFoundError: No module named 'radio'
ModuleNotFoundError: No module named 'radio'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'radio' How to remove the ModuleNotFoundError: No module named 'radio'
ModuleNotFoundError: No module named 'radio'
ModuleNotFoundError: No module named 'radio'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'radio' How to remove the ModuleNotFoundError: No module named 'radio'
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.
ModuleNotFoundError: No module named 'react-buttons'
ModuleNotFoundError: No module named 'react-buttons'  Hi, My... 'react-buttons' How to remove the ModuleNotFoundError: No module named 'react-buttons' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django-buttons'
ModuleNotFoundError: No module named 'django-buttons'  Hi, My... named 'django-buttons' How to remove the ModuleNotFoundError: No module named 'django-buttons' error? Thanks   Hi, In your python

Ads