import javax.swing.*;
import java.awt.*;

/** A simple way to group several radio buttons in a single row, 
 *  with a label on the left.
 *
 *  Taken from Core Web Programming from 
 *  Prentice Hall and Sun Microsystems Press,
 *  http://www.corewebprogramming.com/.
 *  &copy; 2001 Marty Hall and Larry Brown;
 *  may be freely used or adapted.
 */

public class RadioButtonPanel extends JPanel {
  public RadioButtonPanel(String labelString, 
                          JRadioButton[] radioButtons,  
			                 ButtonGroup buttonGroup) {
    setLayout(new FlowLayout(FlowLayout.LEFT));
    add(new JLabel(labelString));
    for(int i=0; i<radioButtons.length; i++) {
      buttonGroup.add(radioButtons[i]);
      add(radioButtons[i]);
    }
  }

  public void setEnabled(boolean state) {
    Component[] components = getComponents();
    for(int i=0; i<components.length; i++)
      components[i].setEnabled(state);
  }
}

