Adding a new component

About this task
You can extend the list of components provided in the toolkit, or replace some components with your own. If additional behavior is required, you can define new classes add them to the original Desktop panel wherever needed. To add a new component to the Desktop, complete the following steps:
  1. Either create brand-new classes, or extend the ones provided in the toolkit to add any required functionality. Create a package for the new classes using a unique name that identifies the project (for example, com.ibm.bankproject.desktop). Do not use the names of the provided component for your own class; instead, add a project identifier as a prefix to the name of the class. For example, if you are extending the ExitButton component, use XyExitButton for your own class name (where Xy is unique to the customer or project). This avoids any conflict with the existing and future components provided by the toolkit. The system will look in the list of packages provided in the XML file to find the class (see the following step).
  2. Add the new package to the list of packages to be handled by the Desktop. The provided components are the classes included in the com.ibm.dse.desktop package. The main class Desktop has a packages parameter where you can include the list of packages containing the classes you are using. You can set this value as an attribute of the Desktop component in the XML file.
    Note: All packages specified in the packages parameter of the Desktop must end with a period (packages="com.ibm.bankproject.desktop."), and two different packages must be separated by a comma (packages="com.ibm.bankproject.desktop., com.ibm.anothername.desktop.").
  3. In addition to methods that provide the component's behavior, add the set of setter methods that are needed to set any external parameters defined in the Desktop configuration file. The name of each setter method must match the name of the attribute it sets as follows: use the Java™ method-naming convention of changing the first letter of the attribute name to uppercase, and then appending "set" (for example, if the parameter name is foregroundColor in the definition file, you must name the method setForegroundColor). These setter methods must accept Object as the unique parameter.
  4. If the class is a container class, which means that it contains sub-elements, then it must implement an additional method called add(Object) to add each component in its list of sub-elements. This method is defined in the DesktopComponent interface, which must be implemented by the new class.
  5. Define in the DTD file the layout of the new class, defining what kind of sub-elements it contains (if any), and the list of possible attributes specified in the XML file for this class. Follow the same structure as for the rest of the components.
  6. Define the corresponding class and its associated attributes in the XML file for every required instance of the component in the Desktop.