Composite Examples
Instances of this class are controls which are capable of containing other controls.
Button Snippet
Example demonstrating CompositeButtonSnippet.
CompositeButtonSnippet.java
Paint Listener Snippet
A Composite — not a Canvas — that draws its whole content from a PaintListener, the shape a
colour-scale editor has: a gradient with a ruler down one side, and a hidden inline Text editor
that pops over a value on demand.
The two panels differ in exactly one thing: the right one owns a child (the editor), the left one
does not. Both must paint identically. If only the left one paints, the composite's children
branch is dropping the draw operations Java emits.
Every other GC example here paints on a Canvas, which is why this path went unexercised.
CompositePaintListenerSnippet.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
Reparent Snippet
Moves nested content the way an RCP workbench does: a part's composite into a hidden shell and
back, tree branches collapsed and expanded, tabs switched, a part hidden and shown. Each step
first names itself in the shell title, then acts.
CompositeReparentSnippet.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
Snippet
Demonstrates the use of Composite with GridLayout and various GridData alignment options.
Shows how to position buttons using different horizontal and vertical alignment combinations.



