Layout Manager Exercise
Modify the applet below so that it adds the different radio buttons to boxes
in a GridLayout.
//Purpose: This applet simply creates radio buttons component
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class test12d extends Applet{
//Set background to yellow,
public void init() {
setBackground(Color.yellow);
setFont(new Font("Helvetical", Font.BOLD, 12));
setLayout( new FlowLayout(FlowLayout.LEFT));
CheckboxGroup group = new CheckboxGroup();
add(new Checkbox("Black", true, group));
add(new Checkbox("Red", false, group));
add(new Checkbox("Green", false, group));
add(new Checkbox("Blue", false, group));
add(new Checkbox("Pink", false, group));
}
//Paint the current key at the current position
public void paint(Graphics g) {
//set drawing color
g.setColor(Color.red);
}
}
|