1) is the sub-class of window
2) with title and zoom angle
3) Inherit from container and add component as add
4) can create an invisible frame object as a string-defined caption
5) BorderLayout can be used as default layout manager
6) Change the default layout manager in SetLayout mode
7) frame is a sub-class of window. It is a window with a caption and a zoom angle. It inherits from Java.awt.Container, so you can add components to the framework using the Add () method. The default layout manager for the framework is border layout. It can be changed in SetLayout () mode.
8) The constructor in the framework class frame (string) creates a new, invisible frame object with the caption specified by string. When it is still in an invisible state, add all components to the frame.
To view the construction method of a frame class in a JDK doc document
public Frame(String title) throws HeadlessException
The title in this method is the caption that is displayed.
The program looks like this:
Package com.ahuier.awt;Import Java.awt.Color;Import Java.awt.Frame;public class myframe extends Frame{public myframe (String title) {super (title);} Span class= "Hljs-keyword" >public static void main (string[] args) {MyFrame frame = new myframe (500, 500); //set width and height frame.setbackground (color.blue); //Set background color frame.setvisible (true); //Settings Visible}}
1) Provide space for components
2) Allow sub-panels to have their own layout manager
3) Add a component with the Add method
(1) Like frames, panels provides space to connect to any GUI component, including other panels. Each panel can have its own cloth management program.
(2) Once a panel object is created, it must be added to the window or frame object in order to be visible. This can be done using the Add () method in the container class.
Package com.ahuier.awt;Import Java.awt.Color;Import Java.awt.Frame;Import Java.awt.Panel;PublicClassFramewithpanelExtendsframe{Publicframewithpanel (String title) {super (title);} public static void Main (string[] args) {Framewithpanel frame = new framewithpanel ( "Frame with panel"); panel panel = new panel (); Frame.setsize (200,200); Frame.setbackground (Color.Black); Frame.setlayout (null); //the layout manager, we set to empty, that is, not to use its own layout manager panel.setsize (100, 100); Panel.setbackground (Color.yellow); Frame.add (panel); //set Panel on frame frame.setvisible (true);}}
Containers (Container) frames and panels