简体   繁体   English

在UML类图中表示swing组件

[英]Representing swing components in UML class diagrams

I have some questions regarding the representation of the gui objects in uml class diagrams. 关于um​​l类图中gui对象的表示,我有一些问题。

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?? 例如,如果a有一个扩展JFrame的类,那么我将使用继承符号设计UML类图,但是在JFrame中,我不需要写下它的所有类变量和方法,而只需要写下我的那些上课会用吗?

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. 比方说,我有一个名为gr.mydomain.exampleproject的包,我有一个扩展JFrame的类。

Is the following approach correct or do I need to put the JFrame in a separate package ( javax.swing )? 以下方法是正确的还是我需要将JFrame放在一个单独的包( javax.swing )中?

在此输入图像描述

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. 是的,您必须将继承符号绘制到JFrame类,但是将JFrame类保留为空,不要在其中放置任何字段或方法。 Everybody knows or can look at the API to see what JFrame contains. 每个人都知道或者可以查看API以查看JFrame包含的内容。 Besides, you would fill up the space with the multitude of methods present in JFrame . 此外,您将使用JFrame存在的众多方法填充空间。

Do it like this: 像这样做:

UML截图

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 ()); 但你可能只是在做一些像frame.setLayout (new LayoutManagerClass ()); (aka just creating the object). (也就是创建对象)。 In this case, it's a dependency relationship. 在这种情况下,它是一种依赖关系。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM