JHotDraw 7: Getting Started

Playing around with the sample code

JHotDraw comes with a number of mini examples and with some sample programs which you can use to get an idea about its capabilities.

The mini examples are located in the org.jhotdraw.sample.mini package. The purpose of the mini examples is to convey a specific aspect or feature of the framework. Most of the mini examples consist only of a single Java class.

The larger sample programs are accessible from the navigation bar on the left side of this page. The executable .jar files are located in the folders named Draw, Net, ODG, PERT, SVG and Teddy. The larger sample programs demonstrate how to build a complete application or applet using JHotDraw.

Looking at the source code

The folder jhotdraw7 is a NetBeans project. If you have the NetBeans IDE, you can open this folder as a project. When you do this, you may have to fix dependencies. All dependent files are located in the jhotdraw7/lib directory.

Once the project is open in NetBeans, you can build and run it. This will most likely start one of the sample programs, which are located in the org.jhotdraw.samples packages.

You can run any of the classes named Main as well as most classes in the org.jhotdraw.sample.mini package.

Integrating JHotDraw into a project of your own

JHotDraw is a framework, and not an API. With new versions of the framework, you likely need to adapt your dependent code. JHotDraw also contains a lot of sample code and default implementations, which you are unlikely to need in your application. And finally, the artwork which ships with JHotDraw (for example the icons) may not match the style of your application. Thats why we think it makes little sense to bundle JHotDraw into a .jar-file, which can be put into the classpath of an application.

We recommend putting the jhotdraw/src/main/java directory in the source classpath of your project, and let javac find the classes which your project actually needs.