What is the relationship between AWT and swing in Java

Source: Internet
Author: User

                                     What is the relationship between AWT and swing in  java   

The

AWT is an abbreviation for the abstract window ToolKit, an Abstraction Windows Toolkit, which provides a set of interfaces that interact with the local graphical interface. There is a one by one correspondence between the graphical functions in AWT and the graphical functions provided by the operating system, which we call peers. That is, when we use AWT to component graphical user interfaces, we are actually leveraging the graphics library provided by the operating system. Because the graphics libraries of different operating systems provide the same functionality, the functionality that exists on one platform may not exist on another platform. To implement the concept of "compile, run everywhere," as the Java language claims, AWT has to implement its platform independence by sacrificing functionality, which means that the graphical capabilities provided by AWT are the intersection of the graphical features provided by various general-purpose operating systems. Because AWT relies on local methods to implement its functionality, we typically refer to the AWT control as a heavyweight control.

Swing is a set of new graphical interface systems built on AWT, providing all the functionality that AWT can provide, and dramatically expanding the functionality of AWT with pure Java code. For example, not all operating systems provide support for tree controls, and Swing uses the basic graphing methods provided in AWT to simulate tree controls. Because Swing controls are implemented with 100% Java code, tree controls designed on one platform can be used on other platforms. Because the local method is not used in swing to implement graphics capabilities, we typically call swing controls a lightweight control.

The fundamental difference between AWT and swing: The AWT is a native-based C + + program that runs faster, and swing is a Java program based on AWT, which runs slowly. For an embedded application, the hardware resources of the target platform are often very limited, and the speed of the application is a crucial factor in the project. In this paradox, the simple and efficient AWT is certainly the first choice for embedded Java. In a standard Java application based on PC or workstation, the limitations of hardware resources on the application are often not the key factors in the project, so the use of swing in standard Java is advocated, that is, the application's functionality is implemented by sacrificing speed.



Popular words: The

AWT is the Abstract Window Component Toolkit, the earliest Java development package for programming graphics applications.
Swing is a newly developed package that addresses AWT's problems, and it is based on AWT

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.