Java Learning: Notes on AWT Components and event handling (1)--frame

Source: Internet
Author: User

The 1.java Abstract Window Toolkit (AWT) contains a number of classes to support GUI design
2.AWT is provided by the Java java.awt package
3. For GUI programming, understand: Container Class (Container), Component (component).
The 4.button,scrollbar.canvas,list,checkbox,textfield,textarea,label class is a class in the java.awt package and is a subclass of the component (component) in the java.awt package.
5.java objects created by subclasses or indirect subclasses of the component class are called components.
6.java an object created by a subclass or indirect subclass of container is called a container.
7. Using the Add () method, you can add components to the container and use the RemoveAll () method to remove all the components in the container, and remove (component) removes the corresponding components.
8. Whenever a container adds or removes components, you should let the container call the Validate () method to ensure that the components in the container are displayed correctly.
9. The container itself is also a component, so you can use the Add () method to add a container to another container. The container being added is called an inline container.

1. Java window

Frame is an indirect subclass of the container class that can be created with a frame or its subclasses when a window can be added to a window, but one window is not allowed to be added to another container because the window is added by default to the monitor screen.

Common ways to 1.1 frame (1) frame ()

Create Untitled window, default layout is BorderLayout layout

(2) Frame (String s)

Create a window titled S, the default layout is BorderLayout layout

(3) public void setbounds (int a,int b,int width,int height)

The initial position of the setting window on the screen is (A, b), width is width, height is height

(4) public void setSize (int width,int height)

The size of the setting window is: high height, width is wide; default position is (0,0)

(5) public void setvisible (Boolean b)

Sets whether the window is visible and is not visible by default

(6) public void Setresizable (Boolean b)

Sets whether the size of the window can be adjusted by default

(7) public void Setextendedstate (int.)

Sets the extended state of the window, which takes the following class constants in the frame class: Maximized_horiz,maximized_vert,maximized_both

(8) public void Dispose ()

Revokes the current window and frees the resource used by the current window

Java Learning: Notes on AWT Components and event handling (1)--frame

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.