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
)?
Yes, you must draw the inheritance symbol to the
JFrame
class, but leave theJFrame
class empty, don't put any fields or methods in it. Everybody knows or can look at the API to see whatJFrame
contains. Besides, you would fill up the space with the multitude of methods present inJFrame
.Do it like this:
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.