In order to add a new node or link to a diagram, create an instance of the item class by calling the new operator and add it to the diagram's Nodes or Links collection. This works the same way for adding both items from your custom class or ones from the predefined JDiagram types.
There are several shortcut methods provided for creating instances of the predefined node and link types. The methods are members of the diagram's Factory object:
Users can draw diagram elements with the mouse. Call setBehavior to specify what type of elements should be created when a user starts drawing. While items are being drawn, the control raises the validation events nodeCreating and linkCreating to let you validate the operation and prevent creating items at a specific location. When the user releases the mouse button, the item is added to the collection that contains items from the same type (for example, the collections returned by the getNodes).
Call the remove method of the collection returned by the getItems method to delete an object from the diagram. The clearAll method clears diagram contents by deleting all objects.
By default, deleting a node also removes its links. Set the AutoDeleteLinks property to false to prevent that, and disconnect the links instead.