Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Representing swing components in UML class diagrams

I have some questions regarding the representation of the gui objects in uml class diagrams.

For example if a have a class which extends the JFrame, then i will design the UML class diagram with the inheritance symbol, but in the JFrame, i do not need to write down all of it's class variables and methods, but only those whose my class will use right??

Second how will i represent that my class will use a specific layout manager? With the association symbol, i quess but i am not sure.


Say for example I have a package named gr.mydomain.exampleproject, and I have a class extending the JFrame.

Is the following approach correct or do I need to put the JFrame in a separate package (javax.swing)?

enter image description here

like image 738
user969245 Avatar asked May 07 '12 13:05

user969245


1 Answers

Yes, you must draw the inheritance symbol to the JFrame class, but leave the JFrame class empty, don't put any fields or methods in it. Everybody knows or can look at the API to see what JFrame contains. Besides, you would fill up the space with the multitude of methods present in JFrame.

Do it like this:

UML screenshot

As for layout managers: I believe the dependency relationship is the correct one in this situation. The association relationship would be correct if you would call methods on the layout manager's class. But you're probably just doing something like frame.setLayout (new LayoutManagerClass ()); (a.k.a. just creating the object). In this case, it's a dependency relationship.

like image 196
Radu Murzea Avatar answered Sep 19 '22 13:09

Radu Murzea