Create an arraylist of JRadioButtons. Every time the user clicks on a JRadioButton (is enabled) go through the list and count how many JRadioButtons have been enabled. If the count is greater than or equal to 12, disable all other radioButtons until the user unselects one.
This is just one of the many ways to go about this,
Hope this helps.
//initiate jradiobutton arraylist (this will be a field at top of class)
buttons = new ArrayList<JRadioButtons>();
//Create buttons with a listener attached
JRadioButton b1 = new JRadioButton("RadioButton One");
b1.setActionListener(myActionListener);
b1.setActionCommand("select");
buttons.add(b1);
//Add rest of buttons in the same way
JRadioButton b2...
//Add the radio buttons to your panel and such
Now when the user clicks on one of your buttons, your actionlistener will trigger, here you can do your check for the amount enabled
public void actionPerformed(ActionEvent e){
//Check if action was a jradiobutton
if(e.getActionCommand().equals("select")){
int count = 0;
//Here check the amount of buttons selected
for(JRadioButton button: buttons){
if(button.isSelected()) count++;
}
//Now check if count is over 12
if(count > 12){
for(JRadioButton button: buttons){
//if the button trying to activate when 12 already have been, disable it
if(button.equals(e.getSource()) button.setSelcted(false);
}
}
}
}
This should disable buttons when already selected and also only allow the user to select 12 of the buttons in the arraylist.