Java Chapter 29th GUI

Source: Internet
Author: User

Getting Started with GUI

The process of JDBC connecting to a database

Registration driver (class, forname)

Create a connection

Create a Connection object

Execute SQL statement

Types and functions of statement objects

1, (layout: layout)

2, (flow: mobile, streaming)

3. (Grid: Border, border)

4. (Title: title)

5, (Size: size, size)

6. (Visible: observable, significant)

7, (East: Eastern, Eastern)

8. (West: Western, West)

9, (South: Southern, Southern)

10, (North: Northern, Northern)

11, (Center: Central, Central)

Learn about AWT

About AWT

Implementing GUI programming is done by a series of graphical components (i.e. a series of well-defined classes)

These components are also referred to as controls;

In earlier versions of Java, the GUI component was abbreviated by the standard library named AWT (Abstract window Toolkit, Abstraction Windows Toolkit), which is a Java Abstract Window Toolkit that provides a number of graphical interface component classes. such as button, TextField, and so on.

In addition to GUI components, AWT includes additional features to support image painting, processing of cut/Copy type data transfer,

and other related operations.
The new swing package in jdk1.2 is also used to make graphical interfaces, with the same functionality as AWT, but more powerful

and java.awt Package

java.awt is a package that contains all the classifications used to create the user interface and draw graphical images.

The java.awt package is a Java built-in package that is part of the Java Base Class Library (JFC).

These include the following:

A rich set of interface components that facilitate user input;

Several layout managers that place components in the appropriate location;

Event processing model;

Graphics and image tools, and more.

To use a class in the package, you must declare the following statement:

Import java.awt.*;

//

Flow Layout (FlowLayout)

Border Layout (BorderLayout)

Grid Layout (GridLayout)

Using panels (JPanel) for complex layouts

The concept of the GUI

So far, all we have written in Java is a console-based program;

GUI (graphical user Interface), which makes the application look friendlier, is a graphical UI

The class architecture for AWT components:

//

//

//

//

//

Common Basic Swing components

In swing programming, there are a number of components that are often used, including:

JFrame (form, frame)

JButton (Button)

JLabel (label)

JTextField (text box)

//

//

//

//

//

Javax.swing.jButton

In a swing program, a button is probably one of the most used components,

The JButton is used to create a button;

There are 5 ways to structure the JButton class, and the following are some common:

Construction Method:

1. (JButton: Create an empty button)

2. (JButton (String text): Create a button with text)

3, (icon icon): Create a button with an icon JButton

4. (JButton (String Text, icon icon): Create a button with text and icon)

//

//

//

//

//

//

//

//

Javax.swing.JPanel

The JPanel provides a panel component, which is a lightweight container component;

The Panel can add other components, you can also set the layout, we generally use the panel to achieve the layout of nesting;

There are 4 ways to construct the JPanel class, and here are some common ones:

JPanel ()---> Create an empty panel

JPanel (LayoutManager layout)----> Create a panel with a specified layout

Common methods of JPanel

GUI Primer Summary

Java Chapter 29th GUI

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.