3

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

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. However, while the article is dated November 9, 2016, it made me wonder about the validity of its content, hence the question here. I was hoping some more experienced programmers could give an up to date, and concrete answer.

root
  • 125
  • 1
  • 10
  • Maybe you could find [some information here](http://www.oracle.com/technetwork/java/architecture-142923.html). – nicovank Nov 12 '17 at 23:10
  • Swing uses an [Event Dispatching Thread (EDT)](https://en.wikipedia.org/wiki/Event_dispatching_thread). – nicovank Nov 12 '17 at 23:18
  • According to that article on EDT, it uses the Worker Design Pattern, which is one I haven't come across before. I doubt we'll have to go into this much detail for the exam, however for personal curiosity reasons I'd like to see just how far this goes. – root Nov 12 '17 at 23:22
  • The `EventListenerList` held by each `JComponent` is examined [here](https://stackoverflow.com/q/2159803/230513). – trashgod Nov 12 '17 at 23:22
  • It uses MVC, observer patters, probably has a factory pattern or two, maybe a builder pattern somewhere in there. There is no "single" pattern at play – MadProgrammer Nov 12 '17 at 23:27
  • Possible duplicate of [*Examples of GoF Design Patterns in Java's core libraries*](https://stackoverflow.com/q/1673841/230513). – trashgod Nov 13 '17 at 13:29
  • If someone could whack an answer up from the comments here, I'll mark it as correct. – root Nov 15 '17 at 01:34

1 Answers1

0

If i understand correct your question For example Command designe pattern used in Action (javax.swing.Action) 

nairavs
  • 475
  • 1
  • 7
  • 22