JFace-Snippets are small and easy understandable programming examples how to use the JFace API. To browse the examples, navigate to the examples GIT repository.
The header section of each snippet is a link to the plain source. You can copy the source and paste it directly on the source folder or package in an eclipse project. The package and the class will be created automatically. Click the icon to see an instruction video.
- 1 Dialogs
- 2 Layout
- 3 Viewers
- 3.1 Snippet001 - Table Viewer
- 3.2 Snippet002 - Tree Viewer
- 3.3 Snippet003 - Table Label Provider
- 3.4 Snippet004 - Hide Selection
- 3.5 Snippet005 - Tree Custom Menu
- 3.6 Snippet006 - Table Multi Line Cells
- 3.7 Snippet007 - Full Selection
- 3.8 Snippet008 - Reveal Element
- 3.9 Snippet009 - Cell Editors
- 3.10 Snippet010 - Owner Draw
- 3.11 Snippet011 - Custom Tooltips
- 3.12 Snippet013 - Table Viewer No Mandatory Label Provider]
- 3.13 Snippet014 - Tree Viewer No Mandatory Label Provider]
- 3.14 Snippet015 - Custom Tooltips For Tree
- 3.15 Snippet017 - Table Viewer Hide Show Columns
- 3.16 Snippet018 - Table Viewer Add Remove Columns With Editing
- 3.17 Snippet019 - Table Viewer Add Remove Columns With Editing
- 3.18 Snippet024 - Table Viewer Explore
- 3.19 Snippet025 - Tab Editing
- 3.20 Snippet026 - Tree Viewer Tab Editing
- 3.21 Snippet027 - Combo Box Cell Editors
- 3.22 Snippet029 - Virtual Table Viewer
- 3.23 Snippet030 - Virtual Lazy Table Viewer
- 3.24 Snippet031 - Table Viewer Custom Tooltips Multi Selection]
- 3.25 Snippet034 - Cell Editor Per Row New
- 3.26 Snippet035 - Table Cursor Cell Highlighter
- 3.27 Snippet036 - Focus Border Cell Highlighter
- 3.28 Snippet037 - Fancy Custom Tooltips
- 3.29 Snippet038 - Tree Viewer Inlinel Editing Old API
- 3.30 Snippet039 - List Viewer
- 3.31 Snippet040 - Table Viewer Sorting
- 3.32 Snippet 041 - Table Viewer Alternating Colors and Viewer Filters
- 3.33 Snippet043 - Tree Viewer Keyboard Editing
- 3.34 Snippet044 - Table Viewer Keyboard Editing
- 3.35 Snippet045 - Table Viewer Fill From Background Thread]
- 3.36 Snippet046 - Update Viewer From Background Thread
- 3.37 Snippet047 - Virtual Lazy Tree Viewer
- 3.38 Snippet048 - Tree Viewer Tab With Checkbox
- 3.39 Snippet049 - Styled Cell Label Provider
- 3.40 Snippet050 - Delegating Styled Cell Label Provider
- 3.41 Snippet051 - Table Centered Image
- 3.42 Snippet052 - Double Click Cell Editor
- 3.43 Snippet053 - Start Editor With Context Menu
- 3.44 Snippet055 - Hide Show Column
- 3.45 Snippet056 - Boolean Cell Editor
- 3.46 Snippet057 - Table Viewer Skip Hidden Cells
- 3.47 Snippet058 - Cell Navigation
- 3.48 Snippet060 - Text Cell Editor With Content Proposal]
- 3.49 Snippet061 - Faked Native Cell Editor
- 3.50 Snippet062 - Text And Dialog Cell Editor
- 3.51 Snippet063 - Combo Viewer
- 4 Window
- 5 Wizard
Demonstrates usage of Icons in Buttons of Dialogs
Drop these icons also in the same package
Demonstrates usage of the GridLayoutFactory to enhance readability
Demonstrates (dynamic)layout support for TableColumns available as of JFace 3.3
Demonstrates (dynamic)layout support for TreeColumns available as of JFace 3.3
Demonstrates tables with more than one column and the usage of ITableLabelProvider
Demonstrates how the selection can be hidden when the user click in a tablerow/column which doesn't hold any information. The standard behaviour of SWT-Table is to leave the selection on the last column. This snippet removes the selection if the user clicks in an area not selectable
Demonstrates how to create a different context menu depending on which item in the tree is currently selected this can also be used with a table of course
Demonstrates first use case for the new OwnerDraw-Support added to JFace in 3.3 (available at SWT-Level since 3.2). This example uses the new Viewers API in this special case the OwnerDrawLabelProvider to make items with more than one line of text.
Demonstrates how you can use a use inline editing in tables with multiple columns which requires to use SWT.FULL_SELECTION but hiding the selection from the user.
Demonstrates how you can scroll a TableViewer to the specific model element using TableViewer#reveal(Object)
Demonstrates minimal example when trying to add inline editing to tables to get familiar with the various classes needed (3.2 API)
Demonstrates usage of new OwnerDraw-Support feature provided by JFace in 3.3(available in SWT since 3.2). This example uses the new Viewers API in this special case the OwnerDrawLabelProvider.
Demonstrates usage of new custom tooltip support in 3.3 used to provide a tooltip for each cell in TableViewer
Demonstrates usage of none mandatory LabelProviders in TableViewers to set colors and fonts with 3.2-API
Demonstrates usage of none mandatory LabelProviders in TreeViewers to set colors and font with 3.2-API
Demonstrates usage of custom tooltip support used to provide a tooltip for each cell in a TreeViewer
Demonstrates hiding and showing of columns (animated)
Demonstrates adding/removing of columns in conjunction with inline editing which makes this a bit tougher than without it (using 3.2 API)
Demonstrates adding/removing of columns in conjunction with the inline editing but with the new JFace-API who makes this a much easier and less error prone
Demonstrates the base classes of 3.3 API
Demonstrates how one can use the new 3.3 API to add tab-editing support to your viewer
Press Tab to jump from cell to cell
Demonstrates all fancy things one can do with new 3.3 API (Tab-Editing, Keyboard-Navigation from Cell to Cell, Editor-Activation with the Keyboard)
Demonstrates usage of the ComboBoxCellEditor in JFace-Viewers
Demonstrates usage of JFace-Viewers in virtual mode with an ordinary content provider (often the bottel neck is not the model but the UI). Using this Virtual viewers in conjunction with an ordinary content provider has the advantage that Sorting and Filtering is supported in 3.3.
Demonstrates usage of JFace-Viewer virtual mode with a lazy content provider
Demonstrates creation of tooltips for cells for pre 3.3 users
Demonstrates different CellEditor-Types in one COLUMN of JFace-Viewers
Demonstrates keyboard navigation in TableViewers using a TableCursor showing the flexibility of the cell navigation support
You also need these classes:
Demonstrates keyboard navigation by highlighting the currently selected cell with a focus border showing once more the flexibility of the cell navigation support
You also need:
Demonstrates customizability of the 3.3 JFace-Support for cell tooltips using the Browser-Widget and presenting HTML
Demonstrates editing support as of 3.2 for TreeViewers
Demonstrates a very simple usage of ListViewer
Demonstrates sorting(asc/desc) in TableViewers by clicking the column header.
Demonstrates how to achieve alternating row-colors with TableViewer. It can also be used in conjunction with virtual-bits to even work with big tables (e.g. 100,000 rows in this example). In addition, this snippet provided a button that will demonstrate the usage of viewer filters.
Demonstrates the JFace 3.3 keyboard editing support for Trees without columns. Tabbing from editor to editor is supported since 3.4. In addition this snippet provided a button that shows how to enter in edit mode programmatically.
Demonstrates the JFace 3.3 keyboard editing support for Tables without columns. Tabbing from editor to editor is supported since 3.4.
You also need:
Demonstrates how a TableViewer with a sorter can be filled from a NON-UI thread
Demonstrates how to update a viewer from a long running task (which is executed in a thread) and calls back to the UI-Thread using asyncExec
Demonstrates the usage of ILazyContentProvider in conjunction with a Virtual-TreeViewer. The snippet shows how using a lazy tree can minimize the memory footprint and maximize the speed when viewing large models.
Demonstrates how to overcome a limitation when it comes to key-navigation and CheckBoxEditors in 3.3.1.
This is a workaround for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=198502
Demonstrates a new LabelProvider-Type which uses StyleRanges. This Snippet requires SWT/JFace 3.4.
Demonstrates how you can add styled text by wrapping an existing label provider. This Snippet requires SWT/JFace 3.4.
Demonstrate how to center an image and create graphics in a cell using owner draw.
Demonstrate how to start cell-editors on double click.
Demonstrate how to start up a cell editor with a context menu and not with mouse clicking on the cell.
Demonstrate hiding and showing columns and starting a cell editor programmatically.
Demonstrate a custom cell-editor which uses a real Checkbox-Button
You also need these classes:
Example of showing how easy cell-navigation with hidden cells is. Use the cursor keys to navigate between cells. Then use the context menu to hide a column.
Shows how to automatically reveal cells when navigating. Run the snippet and then edit the first cell by double clicking. Pressing tab will advance to the next cell in edit mode and reveal the cell if it is not in the viewport.
Show how to use content-proposal inside a CellEditor
Full featured native looking viewer with checkboxes in an arbitary column
You also need these classes:
Demonstrates usage of TextAndDialogCellEditor. The email column uses the TextAndDialogCellEditor; othe columns use ordinary TextCellEditor.
You also need these classes:
Show how to use ComboViewer and set a inital selection
Demonstrates usage of new JFace 3.3 to show really cool ToolTips for your controls
For full fun you also need:
Demonstrates creation of ToolTips for Tables without using the JFace-Viewers API but only JFace-Tooltips
Demonstrates how to work with JFace-Wizards and fill a TableViewer from a Background-Thread without blocking the UI showing a progress bar in the meanwhile
Demonstrates a wizard with internal progress.
Demonstrates a wizard with internal progress using SubMonitor and subtasks.