In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is to share with you about the difference between Swing and SWT. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Introduction to Swing and SWT
The main reason for Swing is that AWT can not meet the needs of the development of graphical user interface. AWT was originally designed to support the development of a simple user interface for small applications. AWT lacks clipboard, print support, keyboard navigation and other features; AWT is weak and does not even include basic elements such as pop-up menus or scrolling panes. In addition, there are other serious flaws in the AWT architecture.
With the development of graphical user interface, Swing appeared. Almost all Swing components are lightweight components. Compared with the relative heavyweight components of AWT, Swing has no native equivalent components. Unlike heavyweight components, which need to be drawn in their own local opaque forms, lightweight components will be drawn in the windows of their heavyweight components.
SWT itself is only a set of low-level graphical interface API written by the Eclipse organization to develop the Eclipse IDE environment. Perhaps inadvertently or intentionally, so far, SWT has surpassed the AWT and SWING provided by SUN in terms of performance and appearance. At present, Eclipse IDE has been developed to version 2.1, and SWT has been very stable. The stability here should have two meanings.
Compare Swing and SWT
1. Component system:
A) Swing: the component tree is dynamically maintained by calling the add () and remove () methods dynamically on the parent component, so there can be child components without a parent component.
B) SWT: by specifying the parent component in the parameters of the constructor, it is impossible to have a child component without a parent component.
2. Component drawing:
A) Swing: by calling the paint () method of the component to draw the component, the component further calls paint () on its child components to complete the drawing of the whole component tree. By subclassing and overriding the paint () method, you can completely customize the drawing of a component.
B) the SWT:SWT component is only an agent of the actual component on the local platform, the actual component is drawn by win32 programming, and the drawing process is not completed in JVM. Therefore, subclassing cannot fully customize the drawing. When the SWT component draws, it returns the JVM after it has finished drawing locally, and then notifies all registered PaintListener, so the component drawing can be modified to some extent by registering the PaintListener.
3. Event model:
A) events in Swing are sent according to the current focus. The parent component cannot filter events. Event listeners in Swing are typed, so the types of events that each component can support are limited by method names. Can't be expanded.
B) events in SWT are also sent according to the current focus. The parent component cannot filter events. SWT supports typed listeners as well as untyped listeners. With addListener (type,listener), we can add listeners of any type to the component.
4. Package design:
A) Swing is a pure component library, it has no graphic operation, and his drawing is finally forwarded to Java 2D to complete.
B) SWT contains a component library and a graphics library, and its structure is similar to that of AWT.
Thank you for reading! This is the end of the article on "what's the difference between Swing and SWT". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.