Lesestoff: Lesson: Applets (The Java™ Tutorials > Deployment)
[code=Java]
public class Checkbox_test extends JApplet {
private static final long serialVersionUID = -6367868076583433598L;
Random r = new Random();
public void init() {
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
this.getContentPane().add(panel, BorderLayout.SOUTH);
JCheckBox[] cb_arr = new JCheckBox[12];
for (int i = 0; i < cb_arr.length; i++) {
String str = Integer.toString(i);
cb_arr[i] = new JCheckBox(str, true);
int r_ = r.nextInt(255);
int g_ = r.nextInt(255);
int b_ = r.nextInt(255);
Color c = new Color(r_, g_, b_);
cb_arr[i].setBackground(c);
panel.add(cb_arr[i]);
}
}
}
[/code]