Java basics and java Basics
Although Java is not the main force in front-end development at present, it is necessary to learn Java GUI programming as part of the basics of Java getting started, in addition, you can make small and interesting graphics programs to increase your learning enthusiasm. This learning summary is a Beginner's notes and experiences. If you cannot describe or make any mistakes, please correct me.
1. The birth and functions of the Swing class library, the main development tool of JavaGUI
A qualified Java Developer should not only master the technology, but also have a certain reserve of Java historical background knowledge. So let's briefly introduce the main class library used for JavaGUI development: Swing.
In the Java 1.0 era, a basic class library for GUI Design Abstract Window Toolkit (abbreviatedAWT. The working principle of the AWT library is to delegate tasks that process user interface elements to the local GUI toolbox of the Target Platform (operating system). The local GUI toolbox is responsible for the creation and action of user interface elements. This method of work isAdvantages and disadvantagesFirst, let's talk about the following benefits:
- The processing speed may be faster.
- It can be adapted to different platforms for "one-time writing, anywhere ".
Disadvantages:
- Perception depends on the target platform.
- Some platforms do not have rich interface components (early stages) such as Windows or Mac ). Therefore, the AWT design work is limited to "minimum public Denominator ".
- Different platforms have different bugs.
1996,NetscapeAnother GUI library IFC is created, which works in the following way:Draw the user interface component in a blank window, while the peer only needs to create and draw a blank window. Sun and Netscape cooperated and improved this method, and created a user interface library named Swing, Which is Swing'sBirth.
However, Swing does not completely replace AWT. So far, Java SE 8 still has two functional libraries: AWT and Swing:
- AWT import java. awt (java is the core package)
- Swing import javax. swing (the javax package is a feature extension package)
The reason why Swing does not completely replace AWT is that Swing is based on the AWT architecture, and Swing only provides more powerful user interface components. AWT is required in Swing programming.Event Processing. Simply put,Swing is the user interface class, and AWT is the underlying mechanism.
Inheritance layers of frameworks and component classes in AWT and Swing
2. Create a JFrame framework
3. Add the Text Component JComponent to the framework.