how get radiobutton index in textfield


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: how get radiobutton index in textfield

  1. #1
    Join Date
    Oct 2005
    Posts
    7

    how get radiobutton index in textfield

    Hi master
    Sir this is my class i am using the radio button and textfield
    ===============
    public class radio extends javax.swing.JApplet {
    public void init() {
    initComponents();
    buttonGroup1.add(jRadioButton1);
    buttonGroup1.add(jRadioButton2);
    buttonGroup1.add(jRadioButton3);
    }
    private void initComponents() {
    buttonGroup1 = new javax.swing.ButtonGroup();
    jRadioButton1 = new javax.swing.JRadioButton();
    jRadioButton2 = new javax.swing.JRadioButton();
    jRadioButton3 = new javax.swing.JRadioButton();
    jTextField1 = new javax.swing.JTextField();
    jTextField2 = new javax.swing.JTextField();

    getContentPane().setLayout(null);

    jRadioButton1.setText("jRadioButton1");
    getContentPane().add(jRadioButton1);
    jRadioButton1.setBounds(140, 30, 104, 24);

    jRadioButton2.setText("jRadioButton2");
    getContentPane().add(jRadioButton2);
    jRadioButton2.setBounds(150, 60, 104, 24);

    jRadioButton3.setText("jRadioButton3");
    getContentPane().add(jRadioButton3);
    jRadioButton3.setBounds(170, 90, 104, 24);

    jTextField1.setText("jTextField1");
    getContentPane().add(jTextField1);
    jTextField1.setBounds(100, 180, 150, 20);

    jTextField2.setText("jTextField2");
    getContentPane().add(jTextField2);
    jTextField2.setBounds(100, 140, 140, 30);

    }
    // Variables declaration - do not modify
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JRadioButton jRadioButton1;
    private javax.swing.JRadioButton jRadioButton2;
    private javax.swing.JRadioButton jRadioButton3;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    // End of variables declaration

    }

    =======================================================================
    Sir my need is when user select any one radio button then
    radioButton index move replace in textfield1 and radioButton title move in textfield2
    because i save the radiobutton index in database
    and when form start then which button true that value received 1 form database

    please give me idea how I control my program

    thank

    aamir

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    I would really like to help you, but I fail to decode what your problem is. Please rephrase your question. Apart from that I cannot see any need for a database to resolve any problem whatsoever in the setup you have presented here.

    As for the radiobutton "index"; If you implement an Actionlistener in your applet you can always check which button is clicked by this approach:
    Code:
    public void actionPerformed(ActionEvent e) {
      if (e.getSource()==jRadioButton1) {
        // blabla
      } else if (e.getSource()==jRadioButton2) {
        // blabla
      } else if (etc. etc.)..
    }
    eschew obfuscation

Similar Threads

  1. textField With array Question
    By donce in forum Java
    Replies: 14
    Last Post: 04-19-2006, 10:54 PM
  2. Replies: 2
    Last Post: 07-19-2005, 07:09 AM
  3. button listener not working
    By DrunkinP in forum Java
    Replies: 0
    Last Post: 03-31-2005, 10:36 AM
  4. Getting the Index of a Request.Form key
    By THarlow in forum Web
    Replies: 0
    Last Post: 02-16-2005, 01:30 PM
  5. Clustered Index vs Non-clustered
    By Michael Tzoanos in forum Database
    Replies: 5
    Last Post: 08-09-2002, 02:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center