How to analyze Swing architecture
Today, I will talk to you about how to analyze the Swing architecture. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something from this article.
The Swing architecture originally used the so-called model-view-control (MVC) pattern for UI tools in Smalltalk systems, and MVC introduced the concept that data sources should be separate from on-screen presentation. This is an excellent architecture that can promote code reuse and program framework. Swing uses a variant of the MVC architecture.
A typical Swing GUI component consists of at least three objects: a Component, a Model, and a UI Delegate. In this framework, Model is responsible for storing data, UI Delegate is responsible for getting data from Model and rendering to the screen, Component is usually responsible for coordinating the operation between Model and Delegate, and is also responsible for embedding Swing into the AWT window system.
Note that UI Delegate objects can be replaced dynamically at run time, which gives Swing a pluggable look (Pluggable Look-And-Feel, PLAF).
Although Swing's MVC structure clearly has the benefits of flexibility, it is often blamed as a source of program slowness. Although more method calls are required to support additional redirects based on the MVC structure, the cost here is small. The results of profile for Swing-based applications show that the cost of model-view separation is negligible, less than 1% of the total cost of CPU, and most of the processing events of the complex Swing user interface are actually spent on the underlying graphics operations. Swing's model-view structure is not the root cause of low performance, it is the key to building extensible programs.
Swing provides components for dealing with large datasets, including JTable, JTree, JList, and JComboBox. These vector components are designed to handle thousands or even millions of data, and to avoid taking up a lot of memory, these components add the concept of renderer to the Swing architecture.
After reading the above, do you have any further understanding of how to analyze the Swing architecture? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.