To inherit from a class that is not part of the model, set the CG::Class::UseAsExternal property for the superclass to Checked. This setting prevents code from being generated for the superclass.
To generate an #include of the superclass header file in the subclass, do one of the following actions:
Another way to inherit from an external class is to exclude the external class from the code generation scope. For example, if you want a class to extend the Java class javax.swing.JTree without actually importing it:
This gives the rest of the model the ability to reference the JTree class without generating code for it. In this way, a class in the model (for example, MyJTree) can inherit from javax.swing.JTree. If the subclass is public, the generated code is as follows:
import javax.swing.JTree;
...
public class MyJTree extends JTree {
...
}
If you need a class to import an entire package instead of a specific class, add a dependency (see Dependencies) with a stereotype of «Usage» to the external package, in this case javax.swing. The generated file is then included the following line:
import javax.swing.*
For more information about using external elements, see Visualization of external elements.