I. Vocabulary comprehension
Two. Figure
Three. Some components
JTextField single-line text box
JTextArea Multi-line text fields
JLabel Label
JComboBox drop-down list
Jcheckbox Check
Jradiobutton Single-choice
JButton button
Four. java.awt Bag
The 1.AWT package is a Java built-in package that includes the following:
① a rich set of interface components that facilitate user input;
② several layout managers to place components in the appropriate location;
③ Event processing model;
④ graphics and image tools, and more.
To use a class in the package, you must explicitly declare the following statement:
Import java.awt.*;
Swing does not have much to do with the local graphics library, which means that whatever operating system uses swing as the interface, the display is the same, and a word about swing is cross-platform. And it can draw a richer graphical interface than AWT. The AWT graphical interface uses a local graphical interface that does not have a cross-platform interface, and the interface that the operating system draws out may be different.
Architecture of control classes in 2.Swing packages
Five. Swing profile and Java.swing package
1.Swing is a lightweight component developed on the basis of AWT, which not only improves the user interface but also requires less system resources than AWT.
Swing is a pure Java component that enables all applications to run on different platforms with a native appearance and the same behavior.
Java. The Swing package contains a series of swing controls that, if you want to use the classes in the package, must explicitly declare the following statement:
Import javax.swing.*;
2.java. The architecture of the control classes in the swing package
Six. Component classes and Container classes
Components (Component): Basic graphic elements such as buttons, text boxes, text fields, multi-select buttons, radio buttons, and so on.
Container (Container): An area where components can be accommodated, and other components can be added on the container. such as: Frame,window and so on.
Note: The container can hold the component, or it can hold a container that is smaller than its capacity level.
Seven. AWT container
1. There are two types of containers: window and panel
The difference between 2.Window and panel
window is a container that can be stored independently; a panel cannot exist alone, it must be placed in a window or its subclasses
Sub-class of 3.Window
Frame: The most commonly used form
Dialog: Dialog box
Eight. Swing GUI framework
Nine. Top-level containers
JFrame: The class for the frame window with a border, a caption, an icon to close and minimize the window, and so on. Applications with GUIs typically use at least one frame window.
JDialog: The class used for the dialog box.
JApplet: Class of Java.applet for using swing components
(Java applets are small applications written in the Java language that can be embedded directly into a Web page and produce special effects.) Pages that contain applets are called java-powered pages, which can be referred to as Java-supported web pages.
When a user accesses such a Web page, the applet is downloaded to the user's computer for execution, but only if the user is using a Java-enabled web browser. Because the applet is executed on the user's computer, its execution speed is not limited by the network broadband or modem access speed, the user can better appreciate the multimedia effect generated by the applet on the webpage.
In Java applets, you can achieve graphics, font and color control, animation and sound insertion, human-computer interaction and network communication and other functions. The applet also provides a variety of window environment development tools called Abstract window TOOLKIT,AWT, but the design of AWT is flawed, and the swing technology is replaced by the Java GUI-built lightweight build. They utilize the GUI elements of a user's computer to create standard graphical user interfaces such as Windows, buttons, scrollbars, and so on. Currently, there are a lot of applet examples on the web to show these features vividly. )
10. Intermediate Container
JPanel: The most flexible, most commonly used intermediate container.
JScrollPane: Similar to JPanel, but also provides scroll bars around large components or extensible components.
Jtablepane: Contains multiple components, but only one component at a time. Users can easily switch between components.
JToolBar: Arranges a set of components (usually buttons) by row or column
(JToolBar is a special swing container for storing components.) This container can be used as a toolbar in our Java applet or program, and can be floated or dragged outside the main window of the program. JToolBar is a simple component that is very easy to use and understand. )
Eleven. Java.Swing.JFrame
The 1.JFrame component is used to create forms in swing programs;
The following are common construction methods for JFrame:
2.JFrame Common methods
Twelve. JPanel container
1.JPanel is the simplest container class. Applications can place other components within the space provided by the Panel.
2.JPanel can only exist in other containers (window or its subclasses) and are generally placed in jframe.
3.JFrame can be divided into several jpanel and then further layout of the components on the JPanel
4. The default layout manager for the panel is the FlowLayout layout manager
5. Cannot set title for JPanel
6.java. Common methods of Swing.jpanel
13. Layout Manager
1. The layout manager is used to:
Determine how components are placed on the container, and determine the size of the component;
The default layout manager for 2.Frame is borderlayout;
Layouts commonly used in 3.JAVA: FlowLayout (Flow layout) BorderLayout (Border layout) GridLayout (Grid layout) GridBagLayout (Grid package layout) cardlayout (Card layout)
14. Creating a Menu
Java GUI programming