Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

JavaWorld Daily Brew

Dynamic check boxes in java



I was asking how could i create dynamic check boxes in java on a button press,especially without knowing the bounds of each check box.Then remove all checked boxes on another button press.Here is my manually created check boxes code

cb1=new JCheckBox("Task 1");
cb2=new JCheckBox("Task 2");
cb3=new JCheckBox("Task 3");
cb4=new JCheckBox("Task 4");
cb5=new JCheckBox("Task 5");
cb6=new JCheckBox("Task 6");
addTask= new JButton("Add Task");
removeTask= new JButton("Remove Checked");
addTask.addActionListener(this);
removeTask.addActionListener(this);

and i set bounds later for each. I want these boxes to be created on the add task button press.Thanks in advance