Eclipse Plugin Development SWT Widget

Source: Internet
Author: User
Tags button type

widgets are widget, which are the elements that make up the user interface, including menu, Item, control, etc., control is the most common.

The structure of the common widgets is as follows:

1. Shell (Widget->control->scrollable->compsite->decorations->shell)

The shell is a "window", that is, the window that pops up when the user triggers the event, is the outermost "Composite" in each window, and is the ancestor Composite that makes up the graphical interface.

The top-level shell is defined as the child of display.

Shell shell = new shell (display);

The display here may be parent.getdisplay (), and the single-threaded thread can be created without first thinking about Display.display by the UI thread.

2. Composite ( widget->control->scrollable->compsite )

Composite as a composite control, that is, in composite you can add other controls (including composite), which is equivalent to a box that can put something in it.

How to define: Composite Composite = new Composite (parent, style);

The parent represents the parents composite control, and the Style is a static integer variable, such as SWT, that is used in the SWT class. BORDER, using the symbol ' | ' Interval SWT constants allows a control to apply multiple styles

composite controls (except for controls where child elements are *item) if you want to add another control, you must first layout, otherwise the controls inside cannot be displayed

To add scroll bars to the outermost composite, you need to define Scrolledcomposite:

Parentcomposite.setlayout (New Filllayout ()); Scrolledcomposite's parent composite layout must be set to Filllayout
Scrolledcomposite scrolledcomposite = new Scrolledcomposite (Parentcomposite, SWT. h_scroll| Swt. V_scroll);
Composite maincomposite = new Composite (SCROLLEDCOMPOSITE,SWT.          NONE); Do not add controls directly to Scrolledcomposite
Scrolledcomposite.setcontent (Maincomposite); Must have, the contents of the Scrolledcomposite is Maincomposite

.....
Scrolledcomposite.setexpandhorizontal (TRUE);
Scrolledcomposite.setexpandvertical (TRUE);
Scrolledcomposite.setminwidth (800);
Scrolledcomposite.setminheight (400);
These 4 methods must be set for the scrollbar to function only if the first two items are true and the latter two are useful

3. Button ( widget->control->button)

Button button = New button (parent, style);

The button type is as follows:

as shown, SWT. Push is a normal button, Swt.check is a Select button, Swt.radio is a radio button, the same group of radio buttons must be in the same parent composite control, the different group of radio buttons must be in a different parent composite control; Swt.arrow is a button with an arrow, by defaultbutton, if you want to implement a different method of the arrow buttons, only need to define the corresponding direction in the style, such as the left-pointing button, style for Swt.arrow | Swt. Laft. These four styles can only appear in the same button's style. Common methods: Button.settext ("string");4. ComboCombo Combo = new Combo (parent, style);There are three types of styles: Swt.drop_down, SWT. Simple, SWT. Read_Only The default type is Swt.drop_downSWT. Drop_down as drop-down listString string[] = {"AAA", "BBB", "CCC"};Combo Combo = new Combo (parent, SWT. Drop_down);Combo.setitem (string); Put the string array into the comboCombo.add ("ddd");//Add a string to comboCombo.select (1); Select an item by defaultCombo.settextlimit (3);//Set the length of the drop-down list displaySWT. Simple is the Normal style, and all the elements are displayed .      SWT. Drop_down and Swt.simple only appear in the same combo. SWT. Read_Only is a read-only style, and a text box cannot be edited, and is typically present at the same time as one of the above two styles

Eclipse Plugin Development SWT Widget

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.