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




Have Programming Question? Ask it here!
 
 
 


micheal
Buttons
1 Answer(s)      3 years and 6 months ago
Posted in : Applet


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.


Advertisement
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



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
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 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
HTML custom buttons
HTML custom buttons  How can I make a form with custom buttons
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
Radio Buttons - Java Beginners
Radio Buttons  Hello Sir, How to create the code for the password recovery page(like forgot gmail password question and answer page)using the radion buttons in display the same page in jsp.I need only how to make the question
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
Handling multiple buttons in HTML Form
Handling multiple buttons in HTML Form  How to handle Handling multiple buttons in HTML Form
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
Buttons with Icons
Java: Buttons with Icons You can create buttons that show text, icons (images), or both.   In this example you will learn how to create Buttons... to use ImageIcons for buttons.   To create a button with an icon  
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
Mouse Buttons, Modifier Keys
Java NotesMouse Buttons, Modifier Keys Mouse Buttons. Java supports up to three mouse buttons. Even if your mouse doesn't have three separate buttons, you can simulate some of the buttons by pressing modifier keys when pressing
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 for reference i have a String having values either "G" or "Y" or "R
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
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
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
Multiple buttons in struts using java script
Multiple buttons in struts using java script  Multiple buttons in struts using java script
Hide buttons in Java Swing
Hide buttons in Java Swing In this section, you will learn how to hide buttons using java swing. For this, we have created three buttons, A, B and C. We have performed an action on C. When you click the button 'C', buttons A and B
how to display a table and buttons in swings - Java Beginners
how to display a table and buttons in swings  Hi frends, Actually... different buttons below this displayed table using swings.....please can any... the table and iam not getting buttons below the table......... Thanking you
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
how to display a table and buttons in swings - Java Beginners
how to display a table and buttons in swings  Hi frends, Actually... different buttons below this displayed table using swings.....please can any... the table and iam not getting buttons below the table......... Thanking you
Radio Buttons in DB Very Urgent - JSP-Servlet
Radio Buttons in DB Very Urgent  Respected Sir/Madam, I am R.Ragavendran.. I got your reply.. Thank you very much for the response. Now I am sending... in the database.Here I need Radio Buttons added dynamically for each Row. When I click
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
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
Buttons
Java: Buttons There are many kinds of buttons, all derived from the AbstractButton class. ComponentsDescription JButton This is a standard button..., ButtonGroup Radio buttons are a group of buttons that can have at most one
how to create directed line between two buttons when i clicked there
how to create directed line between two buttons when i clicked there  Hi I have to create a topology between 6 nodes. 6 nodes are created as 6 buttons and when i clicked in first button and then on second button a directed
write a program for creating html page with images and 2 buttons
write a program for creating html page with images and 2 buttons  write a program for creating html page with images and 2 buttons
Multiple submit buttons in single xhtml form - Java Server Faces Questions
Multiple submit buttons in single xhtml form  Hi all, Here I am attaching the source of the page , which containig two submit buttons. Somebody suggested to keep eaxh button in different form. I am new to JSF, can anyone split
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
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
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
disable backward and forward buttons of the browsers - JSP-Interview Questions
disable backward and forward buttons of the browsers  Dear, Thanks for your last reply. I want if you help me to disable the backward of forward of the browser by program using javascript or java. Sometimes when i access
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
disable backward and forward buttons of the browsers - JSP-Interview Questions
disable backward and forward buttons of the browsers  Dear, Please can you help me : I want to disable backward and forward buttons of the browsers (internet Explorere, Mozilla, Firefox, netscape and so). Is it possible
How can I Define a JFrame subclass that has four vertically positioned buttons. - Java Beginners
How can I Define a JFrame subclass that has four vertically positioned buttons... positioned buttons. The labels for the four buttons are Senior, Junior, Sophomore...; public DisplayButtons(){ JButton[] buttons = new JButton[4]; panel=new JPanel(new
 

 

 

DMCA.com