Buttons

Ads
 

Buttons

I have created a web page with radio button group with two radio buttons for accepting the home appliances categories,Kitchen appliances and other appliances.I want to check for the appliance chosen when the required radio button is selected.Which event listener do I need to implement for this task.

View Answers

February 11, 2011 at 3:31 PM

Java Swing action on JRadioButtons

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class RadioButtons extends JFrame {
  private JRadioButton b1, b2, b3;

  public RadioButtons() {
    setLayout(null);
    ButtonGroup group = new ButtonGroup();
    b1 = new JRadioButton("home appliances");
    b2 = new JRadioButton("kitchen appliances");
    b3 = new JRadioButton("other appliances");

    group.add(b1);
    group.add(b2);
    group.add(b3);
   b1.setBounds(10,10,100,20);
   b2.setBounds(10,40,100,20);
   b3.setBounds(10,70,100,20);
    add(b1);
    add(b2);
    add(b3);
    b1.addActionListener(new MyAction());
    b2.addActionListener(new MyAction());
    b3.addActionListener(new MyAction());

    setSize(300,150);
    setVisible(true);
  }

  public static void main(String[] args) {
   new RadioButtons();
    }

public class MyAction implements ActionListener{
    public void actionPerformed(ActionEvent e){
     JOptionPane.showMessageDialog(null,"You have selected " + e.getActionCommand());
    }
  }
}

For more information, visit the link JRadioButtons Example

Ads









Related Tutorials/Questions & Answers:
Buttons
Buttons  I have created a web page with radio button group with two radio buttons for accepting the home appliances categories,Kitchen appliances and other appliances.I want to check for the appliance chosen when the required
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
Advertisements
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
uinavigationcontroller add multiple buttons
uinavigationcontroller add multiple buttons  How to add multiple buttons to the UINavigationController
3 RADIO BUTTONS
3 RADIO BUTTONS  3 RADIO BUTTONS USING ALSO ONE RADIO CLICKING HOW TO PROCESS OF NEXTPAGE
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
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 '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
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
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
space between buttons iPhone SDK
space between buttons iPhone SDK  Hi, can any one please explain how... UIButton's and added them to my UIScrollView. But problem is that those buttons... buttons. Thanks
how to upload and download images using buttons in jsp?
how to upload and download images using buttons in jsp?  how to upload and download images using buttons in jsp
How can combine threads and buttons?
How can combine threads and buttons?  I would like to start an application, stop it and restart it again and stop etc. I tried the following code... TestActionEvent(); frame.setTitle("Two buttons
understanding buttons :JSP random no program
understanding buttons :JSP random no program  I hav java random no generator program but i need to implement it in JSP such that page generates... "no is greater" please help me to understand buttons .thank you java code for random
ModuleNotFoundError: No module named 'django-admin-action-buttons'
ModuleNotFoundError: No module named 'django-admin-action-buttons'  ...: No module named 'django-admin-action-buttons' How to remove the ModuleNotFoundError: No module named 'django-admin-action-buttons' error? Thanks
ModuleNotFoundError: No module named 'django-admin-action-buttons'
ModuleNotFoundError: No module named 'django-admin-action-buttons'  ...: No module named 'django-admin-action-buttons' How to remove the ModuleNotFoundError: No module named 'django-admin-action-buttons' error? Thanks
ModuleNotFoundError: No module named 'django-admin-action-buttons'
ModuleNotFoundError: No module named 'django-admin-action-buttons'  ...: No module named 'django-admin-action-buttons' How to remove the ModuleNotFoundError: No module named 'django-admin-action-buttons' error? Thanks
ModuleNotFoundError: No module named 'monocle_social_buttons'
ModuleNotFoundError: No module named 'monocle_social_buttons'  Hi...: No module named 'monocle_social_buttons' How to remove the ModuleNotFoundError: No module named 'monocle_social_buttons' error? Thanks   Hi
Create Multiple Buttons
Create Multiple Buttons using Java Swing   ... buttons labeled with the letters from A to Z respectively. To display them, we have created an array of letters. Using this array, we have labeled the buttons
php form having 2 submit buttons
php form having 2 submit buttons  i have a php form and some text boxes.and 2 buttons"approve" and "disapprove". when i click on approve button the data from form should go in mysql database and mail should go to appropiate
Java App - Add, Delete, Reorder elements of the buttons
of these elements ... Let us put these buttons in a JPanel called btnsUnit
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
ModuleNotFoundError: No module named 'odoo10-addon-web-access-rule-buttons'
ModuleNotFoundError: No module named 'odoo10-addon-web-access-rule-buttons...: ModuleNotFoundError: No module named 'odoo10-addon-web-access-rule-buttons' How...-buttons' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'odoo11-addon-web-access-rule-buttons'
ModuleNotFoundError: No module named 'odoo11-addon-web-access-rule-buttons...: ModuleNotFoundError: No module named 'odoo11-addon-web-access-rule-buttons' How...-buttons' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'odoo9-addon-web-access-rule-buttons'
ModuleNotFoundError: No module named 'odoo9-addon-web-access-rule-buttons' ...: ModuleNotFoundError: No module named 'odoo9-addon-web-access-rule-buttons' How to remove...-buttons' error? Thanks   Hi, In your python environment you have
How to create dynamic buttons for adding products on a cart.
How to create dynamic buttons for adding products on a cart.  Hi. I have some problems creating a page to add items into a cart. The page loads dynamic products from a database, and i would like to know how to group this products

Ads