The JAVAAPI provides two sets of components for writing graphical interfaces, AWT and swing
Swing is a lightweight GUI component that uses an MVC architecture to design component classes, which are divided into models, attempts, and controllers. The controller handles the interaction of the user with the component, and the model is used to store the data that defines the component.
Views are composed of containers and components. To be visible, a component must be placed in a container.
Heavyweight containers include jframe (form), JDialog (dialog box), JWindow (window), JApplet (applet). There must be at least one heavyweight container (top-level container) in each application.
These 4 top-level containers inherit from the container class.
Lightweight containers include JPanel (panel), JSplitPane (delimited form), JScrollPane (scroll pane), they come from the JComponent class, and lightweight containers can be nested with each other.
Component
Jlbale basic methods include setting up text, pictures, alignment, and other components of the label description.
JButton (button), the action we expect will appear after we click.
Jtexxfield (text field), adding text
Layout of components
1,flowlayout (Flow layout)
2,borderlayout (Border layout)
3,gridlayout (Grid layout)
4,boxlayout (Box Layout)
5, free layout
The latest Java event handling method is to generate events based on the authorization event model event source and send it to one or more listener listeners simply by waiting until it receives an event. Once the event is accepted, the listener processes the events and then returns.
Event: In the authorization event model, an event is an object that describes the state of the event source change.
Events can be generated directly or indirectly through the mouse, keyboard, and GUI interfaces. such as: Press a button, enter a character through the keyboard, select an item in the list box, click a mouse, and so on.
Java Graphical user interface