title: How to get the selected RadioButton from JTable
body: <p>i'm workin on programe and i need to get the selected radio buttom from a Jtable</p>
  
  <p>I found an exemple that i'm workin on </p>
  
  <p>there is to class </p>
  
  <p>the 1st :</p>
  
  <pre><code>  import java.awt.Component;
    import java.awt.event.ItemEvent;
    import java.awt.event.ItemListener;
  
   import javax.swing.DefaultCellEditor;
   import javax.swing.JCheckBox;
   import javax.swing.JRadioButton;
   import javax.swing.JTable;
   import javax.swing.table.TableCellRenderer;
  
   class RadioButtonRenderer implements TableCellRenderer {
     public Component getTableCellRendererComponent(JTable table, Object value,
         boolean isSelected, boolean hasFocus, int row, int column) {
       if (value == null)
         return null;
       return (Component) value;
     }
   }
  
   class RadioButtonEditor extends DefaultCellEditor implements ItemListener {
     /**
       * 
        */
       private static final long serialVersionUID = 1L;
   private JRadioButton button;
  
     public RadioButtonEditor(JCheckBox checkBox) {
       super(checkBox);
     }
  
     public Component getTableCellEditorComponent(JTable table, Object value,
         boolean isSelected, int row, int column) {
       if (value == null)
         return null;
       button = (JRadioButton) value;
       button.addItemListener(this);
            return (Component) value;
     }
  
     public Object getCellEditorValue() {
       button.removeItemListener(this);
       return button;
     }
  
     public void itemStateChanged(ItemEvent e) {
       super.fireEditingStopped();
     }
   }
  </code></pre>
  
  <p>and the 2nd class is :</p>
  
  <pre><code>     package TP2;
       import java.awt.event.ActionEvent;
                import java.awt.event.ActionListener;
       import java.awt.event.ItemEvent;
  
       import javax.swing.ButtonGroup;
       import javax.swing.ButtonModel;
       import javax.swing.JButton;
       import javax.swing.JCheckBox;
       import javax.swing.JFrame;
       import javax.swing.JPanel;
       import javax.swing.JRadioButton;
       import javax.swing.JScrollPane;
       import javax.swing.JTable;
       import javax.swing.JToggleButton;
       import javax.swing.event.TableModelEvent;
       import javax.swing.table.DefaultTableModel;
  
       import net.miginfocom.swing.MigLayout;
  
       public class tablesDesEtudiants extends JFrame {
  
             public tablesDesEtudiants(Object[][] objt) {
               super("List des etudiants");
  
             //  UIDefaults ui = UIManager.getLookAndFeel().getDefaults();
  
              // UIManager.put("RadioButton.focus", ui.getColor("control"));
  
               DefaultTableModel dm = new DefaultTableModel();
               dm.setDataVector(objt , new Object[]                           {"Nom","Prénom","Année","Succs","Type","Select"});
  
               JTable table = new JTable(dm) {
                 public void tableChanged(TableModelEvent e) {
                   super.tableChanged(e);
                   repaint();
        }
      };
      final ButtonGroup group1 = new ButtonGroup();
      for(int i =0 ; i&lt;objt.length;i++){
      if(objt[i][1]!=null)
  
          group1.add((JRadioButton) dm.getValueAt(i, 5));
      }
     // System.out.println(objt.length);
  
      table.getColumn("Select").setCellRenderer(new RadioButtonRenderer());
      table.getColumn("Select").setCellRenderer(new RadioButtonRenderer());
      table.getColumn("Select").setCellRenderer(new RadioButtonRenderer());
      table.getColumn("Select").setCellRenderer(new RadioButtonRenderer());
      table.getColumn("Select").setCellRenderer(new RadioButtonRenderer());
      table.getColumn("Select").setCellEditor(new RadioButtonEditor(new JCheckBox()));
  
  
  
  
     JScrollPane scroll = new JScrollPane(table);
  
     JButton bView = new JButton("View");
     bView.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
  
  
              ButtonModel choix   = group1.getSelection();
              if (choix != null) {
  
              System.out.println( choix.getActionCommand());
                              }
              else System.out.println("nullll");
          }
      });
  
  
     JPanel  pp =new JPanel();
     MigLayout layout = new MigLayout(
  
            "",           // Layout Constraints
            "[][]20[]",   // Column constraints
            "[]20[]");    // Row constraint
  
  
        pp.setLayout(layout);
        pp.add(scroll,"cell 1 2");
  
        pp.add(bView,"cell 2 3");
     getContentPane().add(pp);
  
  
      setSize(600, 400);
      setVisible(true);
  
  
    }
  
  
   /* public static void main(String[] args) {
      JRadioButtonTableExample frame = new JRadioButtonTableExample();
      frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
          System.exit(0);
        }
      });
    }*/
  }
  </code></pre>
  
  <p>in the 2nd class i'm trying to add all the radio button on ButtonGroup
  like this :</p>
  
  <pre><code>   final ButtonGroup group1 = new ButtonGroup();
      for(int i =0 ; i&lt;objt.length;i++){
      if(objt[i][1]!=null)
  
          group1.add((JRadioButton) dm.getValueAt(i, 5));
      }
  </code></pre>
  
  <p>and my problem is that i can't get selected RadioButton :</p>
  
  <pre><code>         ButtonModel choix  = group1.getSelection();
              if (choix != null) {
  
              System.out.println( choix.getActionCommand());
                              }
              else System.out.println("nullll");
          }
  </code></pre>
  
  <p>i alwayse get nullll</p>
  
  <p>any help plz !!</p>