Home  >  Article  >  Java  >  What is swing in java

What is swing in java

青灯夜游
青灯夜游Original
2019-05-17 16:42:108374browse

What is swing in java

Swing is a development toolkit (GUI toolkit) for developing Java application user interfaces. It is part of the JAVA basic class; it includes graphical user interface (GUI) devices , such as: text boxes, buttons, split panes and tables.

Swing is based on the Abstract Window Toolkit (AWT) so that cross-platform applications can use any pluggable appearance style. Swing developers can take advantage of Swing's rich, flexible features and modular components to create elegant user interfaces with only a small amount of code. All packages in the toolkit are named with swing, such as javax.swing,javax.swing.event.

Swing provides many better screen display elements than AWT. They are written in pure Java, so they can run cross-platform like Java itself, unlike AWT. They are part of JFC. They support replaceable panels and themes (default specific themes for various operating systems), but do not actually use the devices provided by the native platform, but only superficially imitate them. This means you can use any panel supported by JAVA on any platform. The disadvantage of lightweight components is that they execute slowly, but the advantage is that they can adopt uniform behavior on all platforms.

Swing class library structure

Swing components all adopt the MVC (Model-View-Controller, model-view-controller) design to realize the display of GUI components. The separation of logic and data logic allows programmers to customize Render to change the display appearance of GUI components to provide more flexibility.

Swing is built around the JComponent component, which extends from the AWT container class. The Swing organizational structure is shown in the figure.

What is swing in java

As you can see from the above figure, Swing components all start with J except for the AbstmctButton class. The Swing container component directly inherits the container component class in the AWT class library, and most other components inherit the JComponet component. Components can be divided into container components and non-container components. Container components include JFmme and JDialog. Among them, JComponent defines lightweight components of non-container classes (JBntton, JPanel, JMenu, etc.).

The above is the detailed content of What is swing in java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn