This example for you to share the Java streaming layout graphical interface code for your reference, the specific content as follows
Package Jisuanqi;
Import java.awt.*;
public class MyFrame extends frame{
//Inherit Frame class public
MyFrame () {
super ("First graphical Interface");
Sets the frame window title
this.setsize (130);
Set assembly dimensions (wide, high)
this.setlocation (+, +);
Sets the display position of the component
This.setbackground (Color.lightgray);
Sets the background color of the component
This.setlayout (New FlowLayout ());
The container layout is set to flow layout, centered
This.add (new Label ("Name:");
Create a label and add it to the frame
This.add (new TextField ("Chen Haoxiang");
Create a line of text, 10 column
This.add (new Label ("password"));
This.add (new TextField);
Creates a 10-column text line
this.add (The New button ("OK"));
Creates a button
This.add (The New button ("Cancel"));
Create button
this.setvisible (true);
Whether to show the frame window, you must after adding the component
} public
static void Main (string[] args) {
new MyFrame ();
}
}
The first time to write a graphical interface source code, a little excitement ah.
The graph construction method of flow layout defaults to center arrangement;
to Chi Chang quantity:
Left (0): aligned
Center (1): Center
Right (2): right-aligned
public flowlayout (int align)
The align parameter specifies the alignment, and the value is the amount of Chi Chang.
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.