SWT: formlayout table layout

Source: Internet
Author: User

// Create a formlayout object
Formlayout = new formlayout ();
Formlayout. marginheight = 5; // you can set up or down to 5 pixels.
Formlayout. marginwidth = 5; // set the Left and Right padding to 5 pixels.
Shell. setlayout (formlayout );

Button Bt1 = new button (shell, SWT. Push );
Bt1.settext ("B1 ");
// Create a formdata object
Formdata = new formdata ();
// Set the position of the upper border of the control
Formdata. Top = new formattachment (30, 70, 60 );
// Set the position of the lower border of the control
Formdata. Bottom = new formattachment (100,-5 );
// Set the position of the Left Border
Formdata. Left = new formattachment (20, 0 );
// Set the position of the Right Border
// Formattachment (INT numerator, int offset)
// Numerator indicates the number of molecules. The default denominator value is 100,
// Offset is the offset, positive offset, and negative offset.
Formdata. Right = new formattachment (100,-3 );
Bt1.setlayoutdata (formdata );

Button bt3 = new button (shell, SWT. Push );
Bt1.settext ("button 1 ");
Formdata formdata1 = new formdata ();
// Set the position of the upper border
Formdata1.top = new formattachment (20, 0 );
// Set the position of the Left Border
Formdata1.left = new formattachment (20,-10 );
Bt3.setlayoutdata (formdata1 );

Button bt4 = new button (shell, SWT. Push );
Formdata1 = new formdata ();
// Set the position of the ending border J.
Formdata1.top = new formattachment (20, 0 );
// 20 pixels to the right of bt3
Formdata1.left = new formattachment (bt3, 20, SWT. Right );
Bt4.setlayoutdata (formdata1 );
Bt4.settext ("wide button 2 ");
Shell. open ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.