JHotDraw Pattern Language

Customising DrawApplication


DrawApplication is responsible for the creation of the graphical user interface (GUI) and for controlling access to the main elements of a JHotDraw application.

DrawApplication is the initialisation point for the framework. it defines a method open(), that initialises all the framework components and combines them together to create the application. The open() method is an obvious target for customisation in applications, however the method should not be overridden directly (as the developer would then have the onus of initialising JHotDraw correctly). Instead the open() method implements the Template design pattern, where open() is the template and methods such as createTools() and createDrawing() provide hooks that developers may override in their own subclasses.

        import CH.ifa.draw.application.DrawApplication;

    public class MainClass{
        public static void main(String[] args){
            DrawApplication drawApp = new DrawApplication("Application title");
            drawApp.open();
        }
    }

DrawApplication is also responsible for setting up the applications GUI.

Applications can also be animated.

Copyright Douglas Kirk