简体   繁体   English

Java Swing使用哪种设计模式?

[英]Which design pattern does Java Swing use?

To be clear, I'm not asking which design pattern to use in my program. 要清楚,我不是要问我的程序中使用哪种设计模式。 I'm asking which design pattern has been used in the creation of the Swing library and the event system used within it. 我问的是在创建Swing库时使用了哪种设计模式以及在其中使用的事件系统。 I'm currently studying a Bachelor of Information Technology, and one of the trial exam questions asked me to describe the Event Model used in swing, and then went on to elaborate that the specific pattern used is the Chain of Responsibility design pattern. 我目前正在攻读信息技术学士学位,其中一个试题要求我描述在秋千中使用的事件模型,然后继续详细说明所使用的具体模式是责任链设计模式。 However, after doing some research, I stumbled across this article: 然而,经过一些研究,我偶然发现了这篇文章:

https://www.developer.com/java/data/understanding-and-using-the-java-delegation-event-model.html https://www.developer.com/java/data/understanding-and-using-the-java-delegation-event-model.html

Which states that from Java 1.1 onwards (and we're up to Java 8 now, almost Java 9), the approach to event handling was based on the "delegation event model" instead. 这表明从Java 1.1开始(现在我们已经达到Java 8,几乎是Java 9),事件处理的方法基于“委托事件模型”。 However, while the article is dated November 9, 2016, it made me wonder about the validity of its content, hence the question here. 然而,虽然该文章的日期是2016年11月9日,但它让我对其内容的有效性感到疑惑,因此这里提出了问题。 I was hoping some more experienced programmers could give an up to date, and concrete answer. 我希望一些更有经验的程序员可以提供最新的,具体的答案。

如果我理解你的问题是正确的例如Action中使用的命令设计模式(javax.swing.Action)

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

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