title: How to set the Radio Button based on the value fetched from the database
body: <p>I have a <code>JTable</code> filled with data about <code>students (student id, name...)</code>, and when I select a row from a table, the form opens and its field need to be filled with same values (eg. if Johny Bravo was selected from the table.</p>
  
  <p>Then his name should be shown in text filed Name on the form, I did like this <code>txtfieldName.setText(student.getName)</code>.</p>
  
  <p>My question is how do I set my <code>Radio button</code> automatically (my radio button is Male or Female) when I clicked the field.</p>
  
  <pre><code>enter code here
  
  tableGuest.addMouseListener(new MouseAdapter() {
  public void mouseClicked(MouseEvent e) {
      try{
          int row = tableGuest.getSelectedRow();
          String guestEdit=(tableGuest.getModel().getValueAt(row,     0).toString());
  
  
          String query = "Select guest_id,guest_fname,guest_lname,guest_contact,guest_age,guest_gender,guest_address,guest_email from guest_tbl where guest_id= '"+guestEdit+"'";
  
      PreparedStatement pst = con.prepareStatement(query);
      ResultSet rs = pst.executeQuery();
  
      buttonGroupEdit.add(rdbtnMaleEdit);
      buttonGroupEdit.add(rdbtnFemaleEdit);
  
  
                  while(rs.next())
                  {
                      String genderEdit=rs.getString("guest_gender"); 
  
                      if(genderEdit.equals("Male"))
                      {
                           rdbtnMaleEdit.setSelected(true); 
                      }
                      else if(genderEdit.equals("Female"))
                      {
                           rdbtnFemaleEdit.setSelected(true);
                      }
                      else
                      {
                      JOptionPane.showMessageDialog(null, "error !");
                      }
  
  
                      tfEditFname.setText(rs.getString("guest_fname"));
                      tfEditLname.setText(rs.getString("guest_lname"));
                      tfEditEmail.setText(rs.getString("guest_email"));
  
                      tfEditContact.setText(rs.getString("guest_contact"))
                  }
                  pst.close();
  
  
              }catch(Exception ex){
                  ex.printStackTrace();
              }
  
          }
      });
  </code></pre>