The ShapeListBox control displays a set of shapes defined in the Shape class.
Namespace: com.mindfusion.diagramming
Package: com.mindfusion.diagramming
Java
![]() |
---|
public class ShapeListBox extends JList<E> |
Shapes from the list box can be dragged to the Diagram drawing canvas to create new nodes. Changing the shape of an existing node can be implemented by handling the shapeSelected event and assigning the selected shape to a node by calling setShape.
Initially, the ShapeListBox displays all shapes accessible through fromId. You can limit the list to only a subset of the available shapes by calling the setShapeFilter method. It is also possible to load a shape library from a file using the ShapeLibrary class, and display the loaded shapes as shown below:
Java
![]() |
---|
ShapeLibrary lib = ShapeLibrary.loadFrom("shapeLib.shl"); |
The control creates an icon image for each shape added. The size of an icon displayed in the list box can be defined by calling the setIconSize method, and setIconMargin specifies the horizontal and vertical margin of the icon.
If the setAllowRename method is called, users can press the F2 key and rename a shape in the list box. When a shape is renamed, the shapeRenamed event is raised. If setAllowRemove is called, list box items can be deleted by pressing the Del key. When a shape is removed, the shapeRemoved event is raised.
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JList(E)
com.mindfusion.diagramming.ShapeListBox