当前位置:网站首页>AWT introduction

AWT introduction

2022-07-04 05:53:00 Gentle ~

Recommended reading :Java Detailed explanation of graphical interface (AWT、Swing) special column

summary

Java Use AWT and Swing Related classes can complete graphical interface programming , among AWT The full name of is abstract window toolset (Abstract Window Toolkit), It is sun The company first provided GUI library , This GUI The library provides some basic functions , But this GUI The function of the library is relatively limited , So later sun The company also provides Swing library . By using AWT and Swing Graphical interface component library provided ,java The graphical interface programming of is very simple , The program only needs to create the required graphic components in turn , And organize these components together in an appropriate way , You can develop a very beautiful user interface .

When JDK 1.0 When it was released , Sun Provides A basic set of GUI Class library , This GUI Class libraries hope to run on all platforms , This basic library is called " Abstract window toolset CAbstract Window Toolkit )", It's for Java The application provides basic graphical components . AWT It's the window frame , It extracts common components from window systems on different platforms , When the program is running , Delegate the creation and actions of these components to the running platform of the program . In short , When using AWT Writing GUI applications when , The program only specifies the location and behavior of interface components , It doesn't provide a real implementation ,JVM Call the operating system local graphical interface to create and platform Consistent counterparts .

Use AWT The created GUI application has the same interface style as the running platform , For example Windows On the operating system , It shows Windows style ; stay UNIX On the operating system , It shows UNIX style . Sun I hope to achieve this in this way " Write Once, Run Anywhere " The goal of .

AWT Inheritance system

All and AWT All programming related classes are placed in the java.awt In the package and its subpackages , AWT There are two base classes in programming :Component and MenuComponent.

Component: Represents one that can be displayed graphically , And can interact with users , for example Button Represents a button ,TextField representative A text box, etc ;

MenuComponent: It represents the menu component of the graphical interface , Include MenuBar ( Menu bar )、 Menultem ( A menu item ) Equal subclass ;

 Insert picture description here

among Container It's a special kind Component, It represents a container , Can hold ordinary Component.

AWT There is also a very important interface called LayoutManager , If there are multiple components in a container , Then the container needs to use LayoutManager To manage the layout of these components .

 Insert picture description here
Recommended reading :Java Detailed explanation of graphical interface (AWT、Swing) special column

原网站

版权声明
本文为[Gentle ~]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/185/202207040535300581.html