Custom layouts for the Eclipse Form Design Guide

Source: Internet
Author: User
Design

3. Custom layout

The Eclipse form provides 2 new layouts

(1) Tablewraplayout

• Problem: If the hyperlink text in the previous example is set to long enough

Link.settext ("This is a example of a form", very much longer and would need to wrap. ");

Even if Swt.wrap is set, the text content is not automatically WRAP because the layout of the body content is GridLayout

· The Eclipse form provides an alternative layout tablewraplayout: similar to GridLayout, but with an automatic wrap function like an HTML table

• The following is an example of an 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 a example of a form", very much longer and would 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);
}

• Here's where the program changes:

1) tablewraplayout substitution GridLayout

2 use Tablewrapdata to provide layout data information

3 Set properties using colspan, rowspan, etc. from HTML table cells

• Note that controls that need to be automatically wrap need to be set to Swt.wrap style

(2) Columnlayout

· Columnlayout is another custom layout provided by the Eclipse form

· Columnlayout is arranged from top to bottom, left to right

• Automatically adjusts the number of control columns to fit the form's width when changing the width of the form

· Columnlayout settings are simple, usually by setting the range of columns (default is 1-3)

In the later part of the relevant section will give examples of use



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.