Regain the basics of java (Nineteen): Summary of simple use of GUI
1. Professional terminology
UI User Interface User Interface 2. CLI Command Line
3. GUI Graphical Interface
4. QQ, WPS, etc. we usually use Many software have GUI, but background service programs do not have UI
2. Java GUI system
java.awt Heavyweight
2. javax.swing lightweight
3. The form and the labels, text boxes, buttons, etc. on the form can be called components or controls
4. GUI API structure chart
a. Component is the top-level parent class component
b. Divided into two groups: container ordinary component
3 , JFrame class
Form with title bar and form button
2. Construction method JFrame() JFrame( String title)
3. Function method setDefaultCloseOperation()
0: means nothing will be done when the close button is clicked
1: means the form will be hidden when the close button is clicked Default
2: Indicates closing the form and ending the program at the same time
4. Commonly used components
For any component, Both contain two parts: properties and actions (events)
2. Single-line text box JTextField class Label JLable class Password box JPasswordField class Button JButton class Text area JTextArea class
3. Functional methods
public String getText() public void setText(String text) public void setSize(int width, int height) public void setLocation(int x , int y)
5. Layout management
Components need to be placed in the form to be displayed and used, which involves layout issues
2. layout
3. Two categories: absolute positioning Using Java’s built-in layout manager
4. Manual absolute positioning
a. Use the upper left corner of the form as the far point
b.setLocation() method
6. Use Java’s built-in layout manager
A class that can implement a certain layout
2. FlowLayout class: flow layout from left to right
3. BorderLayout class : Divide a form into East, West, North, South, Center by default
4. GridLayout class: Grid layout Divide a form into several rows and columns
7. Event listening mechanism
Bind the function to the interface
2. Event driven Process driven
3. Event itself: Mouse-related events Keyboard-related events Form-related events User operations on the interface Class
4. Event source: Which component the event occurs on Class
5. Listener: Yes An interface, specifically using the implementation class of the interface
6. We need to customize a listener class, implement the xxxListener interface, and then rewrite the relevant methods to call the event source.addxxxListener(new listener class( )) method for binding
8. Dialog box
The dialog box is also a component like the button, JOptionPane class
2. public static void showMessageDialog(Component parentComponent, Object message)
9. Adapter design pattern
1. Adapter Adapter2. Implement The relationship is converted into an inheritance relationship, and the empty implementation class of that interface is called the adapter class
10. Use the WindowBuilder plug-in to achieve visual development
The above is the summary of Regaining the Basics of Java (Nineteen): Simple Use of GUI. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

The article discusses using Maven and Gradle for Java project management, build automation, and dependency resolution, comparing their approaches and optimization strategies.

The article discusses creating and using custom Java libraries (JAR files) with proper versioning and dependency management, using tools like Maven and Gradle.

The article discusses implementing multi-level caching in Java using Caffeine and Guava Cache to enhance application performance. It covers setup, integration, and performance benefits, along with configuration and eviction policy management best pra

The article discusses using JPA for object-relational mapping with advanced features like caching and lazy loading. It covers setup, entity mapping, and best practices for optimizing performance while highlighting potential pitfalls.[159 characters]

Java's classloading involves loading, linking, and initializing classes using a hierarchical system with Bootstrap, Extension, and Application classloaders. The parent delegation model ensures core classes are loaded first, affecting custom class loa


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Zend Studio 13.0.1
Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download
The most popular open source editor