Skip to content

Latest commit

 

History

History
503 lines (427 loc) · 124 KB

File metadata and controls

503 lines (427 loc) · 124 KB

SWT Snippets

Snippets are minimal stand-alone programs that demonstrate specific techniques or functionality. Often a small example is the easiest way to understand how to use a particular feature. (If you are looking for large examples, like ControlExample, see the SWT Examples, and if you are programming with JFace, you may find these JFace Snippets useful).

Snippets also help isolate problems. The best way to report an SWT bug is to write your own snippet showing the problem and paste it into the bug report. For a snippet template, see the Hello World example.

Note that the examples here are often edited for brevity rather than completeness. They are intended to guide the reader towards the correct solution, rather than be finished products. These snippets are tested against the HEAD stream and may sometimes reference new API or require bug fixes from there.

To run a snippet, simply import SWT into your Eclipse workspace, create a new Java project that depends on SWT, copy the desired snippet to the clipboard, and paste it into a new snippet class. (If you are using eclipse 3.2 M1 or earlier, you need to create the class using the New Class wizard before pasting; but since 3.2 M1 you can simply select your project and paste, and the class is created for you). Run by selecting the class and then selecting Run > Run As > Java Application.

To contribute a new snippet, create a snippet contribution as a pull request. Thanks in advance for your contribution!

List of Snippets

Hello World

Accessibility

Browser

BusyIndicator

Button

Canvas

Caret

CCombo

Clipboard

Color and RGB

Combo

Composite

Control

CoolBar

CTabFolder, CTabItem

Cursor

DateTime

DirectoryDialog

Display

Drag and Drop

ExpandBar

FileDialog

Font

FormLayout

GC

Gesture, Touch support

GridLayout

Image

ImageData

Label

Link

List

Menu

Monitor

OLE and ActiveX

OpenGL

Path, Pattern

Printing

Program

ProgressBar

RowLayout

Sash

SashForm

Scale

ScrolledComposite

Shell

Slider

Spinner

StackLayout

StyledText

Swing/AWT

TabFolder, TabItem

Table, TableItem, TableColumn

TableCursor

TableEditor

TaskBar, TaskBarItem

Text

TextLayout, TextStyle

ToolBar, ToolItem

Tool Tips

Tracker

Tray, TrayItem

Tree, TreeItem, TreeColumn

TreeCursor

TreeEditor