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