package gui.run;
import gui.ClosableJFrame;
import javax.swing.*;
import java.awt.*;
public class RadioButtonTest extends ClosableJFrame {
Container c = getContentPane();
ButtonGroup bg = new ButtonGroup();
public void addColorButton(RunRadio rr) {
c.add(rr);
bg.add(rr);
}
public RadioButtonTest() {
super("Using Button Groups");
c.setLayout(new FlowLayout());
addColorButton(new RunRadio("cyan") {
public void run() {
c.setBackground(Color.cyan);
}
});
addColorButton(new RunRadio("yellow") {
public void run() {
c.setBackground(Color.yellow);
}
});
addColorButton(new RunRadio("green") {
public void run() {
c.setBackground(Color.green);
}
});
c.setBackground(Color.white);
setSize(250, 300);
setVisible(true);
}
public static void main(String args[]) {
RadioButtonTest app = new RadioButtonTest();
}
}