如何在UML-Designer类图中为Java类添加List等集合类型字段?
How to Add Collection-Type Fields (like
List) in UML Designer Class Diagrams Hey there! I’ve dealt with this exact problem when designing Java projects with UML Designer, so let me break down the step-by-step process to get those List/Collection fields added correctly:
- Open the class attribute editor: Either right-click your target class and select Properties, or double-click the class to open its details panel. Navigate to the Attributes/Fields section.
- Manually input the collection type: In the Type field of the new attribute, directly type the full generic syntax, like
List<String>orList<YourCustomClass>. UML Designer accepts this Java-style type notation even if it doesn’t auto-complete at first. - Use the Type Selection dialog (for auto-completion): If you prefer to pick the type from a list, click the browse icon (usually a magnifying glass or three dots) next to the Type field. In the dialog, switch to the Java Types tab, search for
java.util.List, select it, and then add your desired element type in the generic parameter field (e.g.,String). - Import the Collection type (for better support): To enable auto-completion and proper UML visualization, you can import the Java collection class into your UML model. Go to Model → Import → Java Type, search for
java.util.Listorjava.util.Collection, and add it to your model. This will make the type appear in auto-complete menus going forward. - Enable generic type support (if needed): If you’re using an older version of UML Designer, check your preferences: go to Window → Preferences → UML Designer → Java, and ensure the Enable Generic Types option is checked. This ensures the tool properly renders and handles generic collection types.
A quick tip: Once you’ve added the collection field, if you’re syncing your UML diagram with a Java project, right-click the class and select Synchronize with Java Code to keep your diagram and code in sync.
内容的提问来源于stack exchange,提问作者Mark Lauer
相关产品推荐
相关产品推荐

