JAVA布局(国外英文资料).doc
文本预览下载声明
JAVA布局(国外英文资料)
GridBagLayout
Set the component location free
The pre-set layout is the setLayout () parameter empty, setLayout (null).
Create a layout in the component (x, y) coordinates and width and height as parameters.
The setBonds (int x, int y, int w, int h)) : the parameters are the coordinates and the width, the height.
SetSize (int, int) sets the size of the component
SetLocation (int, int) sets the coordinates of the component
Example: Rectangle re = new Rectangle (10, 10, 50, 30);
Button. The setBounds (re);
FlowLayout
The constructor:
FlowLayout () : set up the order layout manager, by default the components on each row will be centered;
FlowLayout (int) : specifies the alignment, no parameters, flowlayout.center, or 1: the components on each line will be centered; Parameter flowlayout.left or 0: left-aligned; Parameter FlowLayout. RIGHT or 2: RIGHT alignment.
FlowLayout (int, int) : FlowLayout. LEFT LEFT, FlowLayout. Parameter 2: horizontal spacing between components, per pixel; Parameter 3: vertical spacing between components, per pixel.
Methods:
SetLayout () : associated the container with the layout manager;
Getalize () : to get the alignment;
Setaliting () : setting up the alignment;
SetHgap () : set horizontal spacing;
SetVgap () : set the vertical spacing.
GridLayout
The constructor:
The GridLayout (int, int) parameter is the number of rows and the number of columns. If the number of rows, the number of columns and the actual discrepancy, satisfy the number of rows first.
The GridLayout (int, int, int, int) parameter one, two: the number of rows and the number of columns; Parameter 3, 4: horizontal spacing and vertical spacing. The default horizontal spacing and vertical spacing are zero.
Methods:
SetHgap () : set horizontal spacing;
SetVgap () : set the vertical spacing.
Border layout
The constructor:
GridBagLayout () : creates a grid bag layout;
GridBagConstraints () : creates a grid bag layout helper. Used to set the properties of the component
显示全部