packagecom.wy;importorg.eclipse.swt.SWT;importorg.eclipse.swt.events.SelectionAdapter;importorg.eclipse.swt.events.SelectionEvent;importorg.eclipse.swt.layout.grouplayout.GroupLayout;importorg.eclipse.swt.layout.grouplayout.LayoutStyle;importorg.eclipse.swt.widgets.Button;importorg.eclipse.swt.widgets.Display;importorg.eclipse.swt.widgets.Label;importorg.eclipse.swt.widgets.Shell;importorg.eclipse.swt.widgets.Text;publicclasstestForm001 {privateText txtName;privateButton btnMyPress;protectedShell shell;/*** Launch the application
*@paramargs*/publicstaticvoidmain(String[] args) {try{
testForm001 window=newtestForm001();
window.open();
}catch(Exception e) {
e.printStackTrace();
}
}/*** Open the window*/publicvoidopen() {finalDisplay display=Display.getDefault();
createContents();newtestEvent001(this);
shell.open();
shell.layout();while(!shell.isDisposed()) {if(!display.readAndDispatch())
display.sleep();
}
}publicText gettxtName()
{returntxtName;
}publicButton getbtnMyPress()
{returnbtnMyPress;
}/*** Create contents of the window*/protectedvoidcreateContents() {
shell=newShell();
shell.setText("SWT Application");
btnMyPress=newButton(shell, SWT.NONE);
btnMyPress.setData("newKey",null);
btnMyPress.setText("buttonbtnMyPressvalue");
Label lblMsg;
lblMsg=newLabel(shell, SWT.NONE);
lblMsg.setText("Labelvalue");
txtName=newText(shell, SWT.BORDER);
txtName.setRedraw(true);finalGroupLayout groupLayout=newGroupLayout(shell);
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(GroupLayout.LEADING)
.add(groupLayout.createSequentialGroup()
.add(groupLayout.createParallelGroup(GroupLayout.LEADING)
.add(groupLayout.createSequentialGroup()
.add(35,35,35)
.add(lblMsg, GroupLayout.PREFERRED_SIZE,111, GroupLayout.PREFERRED_SIZE))
.add(groupLayout.createSequentialGroup()
.add(78,78,78)
.add(btnMyPress, GroupLayout.PREFERRED_SIZE,151, GroupLayout.PREFERRED_SIZE))
.add(groupLayout.createSequentialGroup()
.add(3,3,3)
.add(txtName, GroupLayout.PREFERRED_SIZE,217, GroupLayout.PREFERRED_SIZE)))
.addContainerGap(263, Short.MAX_VALUE))
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(GroupLayout.LEADING)
.add(groupLayout.createSequentialGroup()
.add(45,45,45)
.add(lblMsg, GroupLayout.PREFERRED_SIZE,44, GroupLayout.PREFERRED_SIZE)
.add(29,29,29)
.add(btnMyPress, GroupLayout.PREFERRED_SIZE,61, GroupLayout.PREFERRED_SIZE)
.add(27,27,27)
.add(txtName, GroupLayout.PREFERRED_SIZE,80, GroupLayout.PREFERRED_SIZE)
.add(55,55,55))
);
shell.setLayout(groupLayout);
shell.pack();//}
}