AWT and Swing, AWTSwing

Source: Internet
Author: User

AWT and Swing, AWTSwing


Layout Classification

I. Streaming Layout


Ii. Border Layout


3. grid layout


Iv. Card Layout


V. Coordinate Layout

You can specify the widget location at will.


6. Hybrid Layout

What is the difference between java awt and swing?

AWT is the abbreviation of Abstract Window ToolKit (Abstract Window ToolKit). This ToolKit provides a set of interfaces for interacting with the local graphic interface. The graphic functions in AWT have a one-to-one relationship with the graphic functions provided by the operating system. We call them peers. That is to say, when we use AWT to construct a graphical user interface, we actually use the graphic library provided by the operating system. Because the graphic libraries of different operating systems provide different functions, functions on one platform may not exist on another platform. To implement the concept of "one-time compilation and running everywhere" declared by the Java language, AWT has to sacrifice its functions to achieve platform independence. That is to say, the graphic functions provided by AWT are the intersection of the graphic functions provided by various general operating systems. Since AWT relies on local methods to implement its functions, we usually call the AWT control a heavyweight control.

Swing is a New GUI system built on the basis of AWT. It provides all the functions that AWT can provide, moreover, AWT functions are greatly expanded with pure Java code. For example, not all operating systems provide support for tree controls. Swing uses the basic plotting method provided in AWT to simulate tree controls. Since Swing controls are implemented using 100% Java code, tree controls designed on one platform can be used on other platforms. Since the local method is not used in Swing to implement graphical functions, we usually call the Swing control a lightweight control.

The basic difference between AWT and Swing: AWT is a local method-based C/C ++ program, which runs fast; Swing is an AWT-based Java program, it runs slowly. For an embedded application, the hardware resources of the target platform are often very limited, and the running speed of the application is a crucial factor in the project. In this case, the simple and efficient AWT has certainly become the first choice for embedded Java. In common standard Java applications based on PCs or workstations, the restrictions imposed by hardware resources on applications are often not a key factor in the project. Therefore, Swing is recommended in Java Standard Edition, that is, the application functions are achieved at the expense of speed.

In general:

AWT is the Abstract Window component toolkit and the earliest java development kit used to write graphics program applications.
Swing is a newly developed package to solve AWT problems. It is based on AWT.

What is the relationship between AWT and Swing in Java?

Of course, it cannot be said that it is completely replaced. Different methods always have different applications.
The AWT interface is implemented by calling the interface elements of the current system. Its appearance is completely dependent on the system.
Swing was later written in java. It is completely made using java and does not rely on any operating system. Therefore, the same program can be achieved, and the same program can be defined in different operating systems. This avoids confusion in layout, color, and frame after awt replaces the operating system. In addition, swing has added many new functions and new methods, enabling programmers to better draw interfaces.

Related Article

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