Java's AWT and swing differ from the contact

Source: Internet
Author: User

AWT is an abbreviation for the abstract window ToolKit (Abstraction Windows Toolkit), which provides a set of interfaces for interacting with the local graphical interface. The graphical functions in AWT have a one by one correspondence with the graphical functions provided by the operating system, which we call peers. In other words, when we use AWT to build a graphical user interface, we are actually using the graphics library provided by the operating system. Features that exist on one platform may not exist on another because of the different functionality that is provided by the graphics library of the operating system. In order to implement the concept of "once compiled, run everywhere" in the Java language, AWT has to implement its platform independence by sacrificing functionality, that is to say, the graphical capabilities provided by AWT are the intersection of the graphical functions provided by various general-purpose operating systems. Since AWT relies on local methods to implement its functionality, we often refer to AWT controls as heavyweight controls.

Swing is a new graphical interface system built on AWT that provides all the functionality that AWT can provide, and dramatically expands 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% of Java code, tree controls designed on one platform can be used on other platforms. Since there is no local method to implement graphics functionality in swing, we often refer to swing controls as lightweight controls.

The basic difference between AWT and swing: AWT is a local method-based C/s + + program that runs faster, and swing is an AWT-based Java program that runs slower. For an embedded application, the hardware resources of the target platform are often very limited, and the running speed of the application is an important factor in the project. In this case, the simple and efficient AWT is, of course, the first choice for embedded Java. In standard Java applications based on PCs or workstations, the limitations of hardware resources on applications are often not critical in the project, so swing is advocated in the standard version of Java, that is, by sacrificing speed to implement the functionality of the application.

Popular words:

AWT is the abstract Window Component Toolkit, the earliest Java development package for programming graphical programming applications.
Swing is a newly developed package to solve the problem of AWT, which is based on AWT.

Java's AWT and swing differ from the contact

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.