Custom Layout of eclipse Form Design Guide

Source: Internet
Author: User

3. custom Layout

Eclipse form provides two new la s

(1) tablewraplayout

· Problem: if the text above is set to long enough

Link. settext ("this is an example of a form that is much longer and will need to wrap .");

Even if SWT. Wrap is set, the text content will not automatically wrap, because the layout of the body content is gridlayout.

· Eclipse form provides alternative layout tablewraplayout: similar to gridlayout, but it has the same automatic wrap function as HTML tables.

· The following is an example of automatic wrap for hyperlink text:

Public void createpartcontrol (composite parent ){
Toolkit = new formtoolkit (parent. getdisplay ());
Form = toolkit. createscrolledform (parent );
Form. settext ("Hello, eclipse forms ");

Composite body = form. getbody ();
Tablewraplayout layout = new tablewraplayout ();
Body. setlayout (layout );
Hyperlink link = toolkit. createhyperlink (body, "Click here.", SWT. Wrap );
Link. addhyperlinklistener (New hyperlinkadapter (){
Public void linkactivated (hyperlinkevent e ){
System. Out. println ("link activated! ");
}
});

Layout. numcolumns = 2;
Link. settext ("this is an example of a form that is much longer and will need to wrap .");
Tablewrapdata TD = new tablewrapdata ();
TD. colspan = 2;
Link. setlayoutdata (TD );
Label Label = toolkit. createlabel (body, "text field label :");
Text text = toolkit. createtext (body ,"");
TD = new tablewrapdata (tablewrapdata. fill_grab );
Text. setlayoutdata (TD );
Text. setdata (formtoolkit. key_draw_border, formtoolkit. text_border );
Button button = toolkit. createbutton (body, "an example of a checkbox in a form", SWT. Check );
TD = new tablewrapdata ();
TD. colspan = 2;
Button. setlayoutdata (TD );
Toolkit. paintbordersfor (body );
}

· The following shows the program changes:

1) tablewraplayout replaces gridlayout

2) use tablewrapdata to provide layout data information

3) The set attributes use attributes such as colspan and rowspan from HTML table cells.

· Note: you need to set the automatic wrap control to the SWT. Wrap style.

(2) columnlayout

· Columnlayout is another custom layout provided by ECLIPSE form.

· The layout of columnlayout is from top to bottom, from left to right

· When the width of the form is changed, the number of control columns is automatically adjusted to adapt to the width of the form.

· Columnlayout is easy to set. Generally, you only need to set the range of columns (the default value is 1-3)

· The following examples are provided in the relevant sections.

Article from: good love Learning Network (http://www.haoxiai.net) Web site: http://www.haoxiai.net/bianchengyuyan/jspjiaocheng/59014.html

Related Article

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.