1 package tim.prune.load;
3 import java.awt.Component;
4 import java.util.ArrayList;
6 import tim.prune.data.Field;
9 * Class to hold a list of Components and fields,
10 * and then enable or disable them (setEnabled) according
11 * to whether those fields are available or not
13 public class ComponentHider
16 * Inner class to hold each Component and its Field
18 static class ComponentPair
20 public Component _component = null;
21 public Field _field = null;
23 public ComponentPair(Component inComponent, Field inField)
25 _component = inComponent;
31 private ArrayList<ComponentPair> _componentList = new ArrayList<ComponentPair>(20);
34 * Add a new component to be controlled
35 * @param inComponent component to enable/disable
36 * @param inField associated field
38 public void addComponent(Component inComponent, Field inField)
40 if (inComponent != null && inField != null) {
41 _componentList.add(new ComponentPair(inComponent, inField));
46 * Enable or disable the components for the given field
47 * @param inField field
48 * @param inEnabled true for enabled, false for disabled
50 public void enableComponents(Field inField, boolean inEnabled)
52 for (ComponentPair pair : _componentList)
54 if (pair != null && pair._field == inField) {
55 pair._component.setEnabled(inEnabled);