Representing swing components in UML class diagrams

元气小坏坏 提交于 2019-12-21 17:52:15

问题


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)?


回答1:


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:

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.



来源:https://stackoverflow.com/questions/10483029/representing-swing-components-in-uml-class-diagrams

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!