Modifying the ImageControls Toolkit Support Hierarchy

The hierarchy of the support classes must match the hierarchy of the custom classes. Now that the ImageControl class is mapped to the support class ImageControlCS, the support classes for the ImageControl descendants must extend ImageControlCS.

Both ImageButtonCS and ImageLabelCS inherit label_attr method. ImageLabelCS needs to override this method to fine-tune its support of the label property.

  1. Modify the ImageButtonCS class to extend ImageControlCS.

    1. Open the file in the ImageControlsSupport project in Eclipse, and locate the ImageButtonCS class signature:

    2. public class ImageButtonCS extends CanvasCS implements ActionListener 
    3. Modify the signature so that ImageButtonCS extends ImageControlCS:

    4. public class ImageButtonCS extends ImageControlCS implements ActionListener
    5. Remove the label_attr method from the ImageButtonCS class.

    6. Save the file.

  2. Modify the ImageLabelCS class to extend ImageControlCS.

    1. In the file, replace public class ImageLabelCS extends CanvasCS with public class ImageLabelCS extends ImageControlCS.

    2. Replace the following lines in the label_attr method in the ImageLabelCS class:

    3. ImageLabel il = (ImageLabel)obj;
      res = il.getImageString();
      if(res == null || res.length() == 0)
              return null;
      int last = res.lastIndexOf('/');
      if(last == -1)
              return res;
      return res.substring(last+1);


      return super.label_attr(obj);
    4. Save the changes.