I have my program working but, I need to cut out the repeated code. How do I change this part of my code to pass arguments to a user defined method? I'm lost. I really have no clue exactly where to start on this. Basically when a user clicks a certain radio button it enables and disables the jlabels and textfield associated with them. Please help.
public void itemStateChanged(ItemEvent choice)
{
if (choice.getStateChange() == ItemEvent.SELECTED)
{
if (optBox.isSelected()==true)
{
txtLength.setEnabled(true);
txtWidth.setEnabled(true);
txtHeight.setEnabled(true);
txtRadius.setEnabled(false);
lblLength.setEnabled(true);
lblWidth.setEnabled(true);
lblHeight.setEnabled(true);
lblRadius.setEnabled(false);
}
else if (optCylinder.isSelected()==true)
{
txtLength.setEnabled(false);
txtWidth.setEnabled(false);
txtHeight.setEnabled(true);
txtRadius.setEnabled(true);
lblLength.setEnabled(false);
lblWidth.setEnabled(false);
lblHeight.setEnabled(true);
lblRadius.setEnabled(true);
}
else if (optCone.isSelected()==true)
{
txtLength.setEnabled(false);
txtWidth.setEnabled(false);
txtHeight.setEnabled(true);
txtRadius.setEnabled(true);
lblLength.setEnabled(false);
lblWidth.setEnabled(false);
lblHeight.setEnabled(true);
lblRadius.setEnabled(true);
}
else if (optSphere.isSelected()==true)
{
txtLength.setEnabled(false);
txtWidth.setEnabled(false);
txtHeight.setEnabled(false);
txtRadius.setEnabled(true);
lblLength.setEnabled(false);
lblWidth.setEnabled(false);
lblHeight.setEnabled(false);
lblRadius.setEnabled(true);
}
}
}//End ItemStateChanged