- UML Modeling on NetBeans, Part 1: Installation
- UML Modeling on NetBeans, Part 2: Create a Use Case Diagram
- UML Modeling on NetBeans, Part 3: Generate code from UML Diagram
- UML Modeling on NetBeans, Part 4: Generate UML Diagram from Code
UML Modeling on NetBeans, Part 2: Create a Use Case Diagram
A Use Case diagram is useful when you are describing requirements for a system in the analysis, design, implementation and documentation stages.
This part will show you how to create a Use Case Diagram on NetBeans.
- Create New Project, File -> New Project…
- In Categories, select UML -> Java-Platform Model. Click Next.
If you can’t see UML, try go back to Part I: Installation
- Type ‘UMLDemo’ in project name or any name you want. Click Finish.
- New window appear, for Diagram type, select Use Case Diagram and named as UseCaseDiagram or any name. Click Finish.
- Now the project has been created and you’ll see Palette window that contain tools for create Use Case Diagram. If you can’t see Palette window, try select tool on menu and choose Palette or press Ctrl + Shift + 8.
Create a Use Case elements
- To create a Use Case element, click on in Palette window and click on the empty space of diagram.
Then type ‘Rent items’ and press Enter.
To change text on a Use Case, right click on the empty space to de-select a Use Case tool in Palette and click on the Use Case Diagram and type some text.
- To create an Actor is the same as previous step. Create an actor named ‘Customer’ and ‘Staff’. The diagram will look similar below.
Create a link between elements
- Next, I’m going to create a link between two Actors. First, select in Palette window. Then click on the ‘Customer’ actor, the arrow appears. Then, click on ‘Staff’ actor.
- To create a stereotype, simply click on the generalization link -> properties -> stereotype -> add -> type ‘implementation’ or stereotype name that you want. Click OK and Close.
- Next, I’m going to link between an Actor and a Use Case. Select in Palette window. Then, click on an Actor ‘Staff’ and a Use Case ‘Rent items’.
- Right-click anywhere in the empty space to de-select the Association link. You’ll see the link color become black.
- Point the cursor to the center of the line representing the link and right-click the Association link. Notice when select the link, color will become blue.
- Select Labels > Link Name from the pop-up menu. Type ‘uses’ and press Enter. The link will show as below.
Create a link between Use Case elements
- Crate a new Use Case element name ‘Maintain customers’.
- Now, I’m going to create include link. Select in Palette window.
- Click once in the Rent items element, and click again in the Maintain customers element. The link appears as below.
- For extend link, use similar way. Try to create extend link as the figure below.
- To rearrange the diagram, click the Orthogonal Layout button on the Diagram toolbar.
- Click Yes in the Layout warning dialog box. The diagram will be rearranged as below. You can try other arrangements that will suit you.
- Click Save to finish.
Export an diagram to image
- Now you have created a diagram, what if you want to save it to a general image file format? Currently, it can export in .jpg, .png, .svg formats.
First, select on the Diagram toolbar.
- Then, select Type of image and destination of file that you want. Click OK and you’re done!.
Now you have a basic to create a Use Case diagram so you can apply these to create other diagram.
Pretty easy, isn’t it?. In coming soon part, I will show how to generate code from the diagram.