FormLayoutGUI.Java
package com.demo.layout;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import com.util.SWTUtil;
public class FormLayoutGUI {
public static final int H_GAP = 20;
private Shell shell;
private FormLayout layout;
private Label lab_title;
private FormData data;
private Label lab_username;
private Text txt_username;
private Label lab_username_info;
private Label lab_password;
private Text txt_password;
private Label lab_password_info;
private Text txt_reppassword;
private Label lab_reppassword;
private Label lab_reppassword_info;
private Label lab_sex;
private Button but_sex_male;
private Label lab_sex_male;
private Button but_sex_female;
private Label lab_sex_female;
private Label lab_country;
private Combo com_country;
private Label lab_province;
private Combo com_province;
private Label lab_interest;
private Button but_interest_dance;
private Button but_interest_music;
private Button but_interest_swim;
private Button but_interest_read;
private Label lab_intro;
private Text txt_intro;
private Button but_reg;
public void init(){
shell = SWTUtil.getShell();
shell.setText("用户注册");
shell.setSize(500, 620);
//定义布局管理器,并设置窗口的内边距
layout = new FormLayout();
layout.marginWidth = 20;
layout.marginHeight = 20;
shell.setLayout(layout);
//标题Label
lab_title = new Label(shell,SWT.NONE);
lab_title.setText("用户注册");
lab_title.setFont(new Font(null,"隶书",24,SWT.NONE));
lab_title.setForeground(new Color(null,200,100,0));
data = new FormData();
data.top = new FormAttachment(2,0);
data.left =