- Adds the listener to in Java

Generator DataMatrix in Java - Adds the listener to
- Adds the listener to
Data Matrix 2d Barcode Maker In Java
Using Barcode drawer for Java Control to generate, create Data Matrix image in Java applications.
the collection of listeners who will be notified when the receiver's selection changes, by sending it one of the messages defined in the SelectionListener interface
Painting Bar Code In Java
Using Barcode maker for Java Control to generate, create barcode image in Java applications.
addTreeListener(TreeListener)
Recognizing Bar Code In Java
Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications.
- Adds the listener to the collec-
Create DataMatrix In Visual C#
Using Barcode drawer for .NET Control to generate, create Data Matrix 2d barcode image in Visual Studio .NET applications.
tion of listeners who will be notified when an item in the receiver is expanded or collapsed by sending it one of the messages defined in the TreeListener interface
DataMatrix Generator In VS .NET
Using Barcode generation for ASP.NET Control to generate, create Data Matrix 2d barcode image in ASP.NET applications.
TT 4 The Simple Widget Toolkit
Paint Data Matrix In .NET Framework
Using Barcode creation for Visual Studio .NET Control to generate, create ECC200 image in VS .NET applications.
deselectAll()
Create Data Matrix In VB.NET
Using Barcode creation for .NET Control to generate, create ECC200 image in VS .NET applications.
- Deselects all selected items in the receiver - Returns the number of items contained in the
Bar Code Maker In Java
Using Barcode printer for Java Control to generate, create barcode image in Java applications.
getItemCount()
EAN13 Generation In Java
Using Barcode creation for Java Control to generate, create EAN-13 Supplement 5 image in Java applications.
receiver that are direct item children of the receiver
Paint Data Matrix In Java
Using Barcode generator for Java Control to generate, create Data Matrix image in Java applications.
getItems()
Bar Code Generation In Java
Using Barcode maker for Java Control to generate, create bar code image in Java applications.
- Returns the number of items contained in the re-
EAN / UCC - 14 Drawer In Java
Using Barcode creation for Java Control to generate, create GTIN - 128 image in Java applications.
ceiver that are direct item children of the receiver
Code11 Generation In Java
Using Barcode printer for Java Control to generate, create USD8 image in Java applications.
getSelection()
Generate Code 3 Of 9 In VS .NET
Using Barcode generation for .NET Control to generate, create ANSI/AIM Code 39 image in .NET applications.
- Returns an array of TreeItems that are cur-
Decode Code 128 In .NET
Using Barcode scanner for .NET framework Control to read, scan read, scan image in VS .NET applications.
rently selected in the receiver
EAN / UCC - 13 Recognizer In .NET Framework
Using Barcode decoder for VS .NET Control to read, scan read, scan image in .NET framework applications.
getSelectionCount()
Data Matrix ECC200 Drawer In Visual Studio .NET
Using Barcode creation for ASP.NET Control to generate, create Data Matrix ECC200 image in ASP.NET applications.
- Returns the number of selected items
Making Barcode In Visual Basic .NET
Using Barcode creation for VS .NET Control to generate, create bar code image in Visual Studio .NET applications.
contained in the receiver
Data Matrix ECC200 Creation In VS .NET
Using Barcode creator for .NET Control to generate, create ECC200 image in .NET applications.
removeAll()
Drawing Code 39 Extended In .NET
Using Barcode generator for ASP.NET Control to generate, create Code 3 of 9 image in ASP.NET applications.
- Removes all of the items from the receiver - Selects all the items in the receiver - Sets the receiver's selection to be
selectAll()
setSelection(TreeItem[])
the given array of items
setTopItem(TreeItem)
- Sets the item which is currently at the
top of the receiver
Useful creation styles include:
SWT Widgets
SWTSINGLE
- Creates a single selection tree widget
SWTMULTI
- Creates a multiple selection tree widget - Creates a check box tree widget
SWTCHECK
Useful TreeItem APIs include:
getChecked()
- Returns true if the receiver is checked, and false
otherwise
getExpanded()
- Returns true if the receiver is expanded, and
false otherwise
getItemCount()
- Returns the number of items contained in the
receiver that are direct item children of the receiver
getItems()
- Returns an array of TreeItems which are the direct
item children of the receiver
getParent()
- Returns the receiver's parent, which must be a
Tree
getParentItem()
- Returns the receiver's parent item, which
must be a TreeItem or null when the receiver is a root
TT 4 The Simple Widget Toolkit
setBackground(Color)
- Sets the receiver's background color to
the color specified by the argument, or to the default system color for the item if the argument is null
setChecked(boolean)
- Sets the checked state of the receiver - Sets the expanded state of the receiver - Sets the receiver's foreground color to
setExpanded(boolean)
setForeground(Color)
the color specified by the argument, or to the default system color for the item if the argument is null
setGrayed(boolean grayed)
- Sets the grayed state of the re-
ceiver
setImage(Image)
- Sets the receiver's image to the argument,
which may be null indicating that no image should be displayed
setText(String)
- Sets the receiver's text
The following example creates a tree with three levels of items (see Figure 4-10) Clicking on an item will print its name to the Console
SWT Widgets
Figure 4-10
import import import import
Tree Example
orgeclipseswt*; orgeclipseswtevents*; orgeclipseswtlayout*; orgeclipseswtwidgets*;
public class TreeExample { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shellsetText("Tree Example"); shellsetBounds(100, 100, 200, 200); shellsetLayout(new FillLayout()); final Tree tree = new Tree(shell, SWTSINGLE); for (int i = 1; i < 4; i++) { TreeItem grandParent = new TreeItem(tree, 0); grandParentsetText("Grand Parent - " + i); for (int j = 1; j < 4; j++) { TreeItem parent = new TreeItem(grandParent,0); parentsetText("Parent - " + j); for (int k = 1; k < 4; k++) { TreeItem child = new TreeItem(parent, 0); childsetText("Child - " + k); } } } treeaddSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { TreeItem[] selected = treegetSelection();
TT 4 The Simple Widget Toolkit
if (selectedlength > 0) { Systemoutprintln("Selected: " + selected[0]getText()); } } }); shellopen(); while (!shellisDisposed()) { if (!displayreadAndDispatch()) displaysleep(); } displaydispose(); } }
After the creation of the Tree widget, new items are created and their labels set with the setText() method Many of the items have child items of their own Finally, a selection listener is added in which a SelectionAdapter is created that overrides the widgetSelected() method in order to print out a selected item
4268 Composite
The Composite widget is used as a container for other widgets The Composite widget s children are widgets contained within the bounds of the composite and resize themselves relative to the composite Useful APIs include:
getChildren()
- Returns an array containing the receiver's chil-
dren
SWT Widgets
layout()
- If the receiver has a layout, asks the layout to lay out
(that is, set the size and location of) the receiver's children
setLayout(Layout)
- Sets the layout which is associated with the
receiver to be the argument which may be null
setTabList(Control[])
- Sets the tabbing order for the specified
controls to match the order that they occur in the argument list
Useful creation styles include:
SWTBORDER
- Creates a composite widget with a border Prevents child radio button behavior
SWTNO_RADIO_GROUP
SWTH_SCROLL
- Creates a composite widget with a horizontal
scroll bar
SWTV_SCROLL
- Creates a composite widget with a vertical scroll
bar
TT 4 The Simple Widget Toolkit
The following example expands upon our earlier Button example by inserting a composite widget between the shell and the button (see Figure 411)
Figure 4-11
Composite Example
import orgeclipseswt*; import orgeclipseswtevents*; import orgeclipseswtwidgets*; public class CompositeExample { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shellsetText("Composite Example"); shellsetBounds(100, 100, 200, 200); Composite composite = new Composite( shell,SWTBORDER); compositesetBounds(25, 25, 150, 125); final Button button = new Button(composite,SWTPUSH); buttonsetBounds(25, 25, 100, 75); buttonsetText("Click Me Now"); buttonaddSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { buttonsetText("I Was Clicked");
SWT Widgets
} }); shellopen(); while (!shellisDisposed()) { if (!displayreadAndDispatch()) displaysleep(); } displaydispose(); } }
A composite widget is created as a child of the shell, and then the composite acts as the parent of the button widget Note that the button is positioned relative to the composite, not the shell