The difference between javase AWT and swing

Source: Internet
Author: User

The AWT component has platform affinity, which is the implementation of the system peer class. Swing components have a consistent performance on different platforms and can provide features that are not supported by the local system, so swing is more practical than AWT's components. Swing uses the MVC (Model-view-controller, model-view-control) design pattern.

(1) Diversification of components
Swing is based on AWT, which provides more graphical interface components than AWT. The class name of the Swing component begins with the letter "J", and in addition to the basic components (button JButton, label JLabel, check box Jcheckbox, menu jmenu) that AWT has, there are many more complex advanced components, such as tables (JTable), Trees ( JTree)

(2) MVC pattern
Swing's salient feature is the pervasive practicality of the MVC model. The MVC model consists of 3 parts: models, views, and controllers. The model is used to hold the data used, the view is used to display the data content, and the controller is used to handle user and module interaction events. When the data of the model is changed, the associated view is notified, and the view is assigned the appropriate mechanism through the controller. To simplify work, Swing components combine views and controllers. The MVC design idea is the graphical user interface design comparison Universal, this can make the content itself and the display way separates, makes the data display more flexible.

(3) Accessibility support
To enable accessibility, all Swing components implement the Accessible interface so that some accessibility (screen readers) can be implemented.

(4) Support keyboard operation
The Registerkeyboardaction () method of the JComponent class can implement the keyboard operation instead of the user mouse operation, which is equivalent to the traditional hotkey operation.

(5) Setting the border
Swing components can set one or more borders, and provide multiple types of borders for the user to select, or even users can create a combo border or their own design border. In addition, blank borders can make the components larger and assist with Layout manager layout.

(6) using the icon
Another richer feature of Swing components is that many components can be decorated with icons.

The difference between javase AWT and swing

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.