本文介绍了在UML类图中表示swing组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对uml类图中gui对象的表示有一些疑问。

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

例如,如果a有一个扩展JFrame的类,那么我将使用继承符号设计UML类图,但是在JFrame中,我不需要写下它的所有类变量和方法,但只有那些我的类才能使用的那些?

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

其次我将如何表示我的类将使用特定的布局管理器?使用关联符号,i quess但我不确定。

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.

比如说我有一个名为<$ c的包$ c> gr.mydomain.exampleproject ,我有一个扩展JFrame的类。

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

以下方法是否正确或是否需要将JFrame放在单独的包中( javax.swing ) ?

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

推荐答案

是的,你必须将继承符号绘制到 JFrame 类,但保留 JFrame 类为空,不要在其中放置任何字段或方法。每个人都知道或者可以查看API以查看 JFrame 包含的内容。此外,您将使用 JFrame 中提供的众多方法填充空间。

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.

这样做:

至于布局管理员:我认为在这种情况下依赖关系是正确的。如果要在布局管理器的类上调用方法,则关联关系将是正确的。但是你可能只是做了类似 frame.setLayout(new LayoutManagerClass()); (仅限创建对象的a.k.a.)。在这种情况下,它是一种依赖关系。

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.

这篇关于在UML类图中表示swing组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-29 22:13
查看更多