How to get the text value of JRadioButton
I am creating a project in java. My Program has 80 JRadioButtons .... I need the get the text value of them.. Now these radiobuttons are added to ButtonGroup(each has 4 radio buttons)... I know how to get the text value from the radio button by this following code radiobutton1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String q1=e.getActionCommand(); JOptionPane.showMessageDialog(null, q1); } }); Now is there any easy way to do this? because i will have to do this above code for 80 times(for eighty radiobuttons if i use the above use the