57 45 4c 4c 20 44 4f 4e 45 21

The SWT Collapsible Buttons Widget is a customizable collapsible buttons widget modeled after the bottom left buttons widget in Microsoft Outlook. The widget is highly customizable from simple flags for setting things on and off, to extending interfaces for controlling how the buttons should be painted and other more advanced aspects.

By default, the widget comes with Default implementations for everything that allows you to skin the button bar according to the following:

  • Outlook 2005 – Windows XP Blue Theme
  • Outlook 2005 – Windows XP Olive Theme
  • Outlook 2005 – Windows XP Silver Theme
  • Outlook 2007 – Blue Theme (Same regardless of XP color scheme)

External Site

This widget is under the Eclipse Nebula project, which is a group of custom written widgets that are not part of the standard SWT API but perhaps aim to be so in the future. This site contains more information and also example snippets that are very useful to understanding how to use the widget. Please visit the Nebula homepage for more information.

Go to the Eclipse Nebula homepage


The Calendar Combo is released under the EPL (Eclipse Public License). It is imperative that you understand what this license allows you to do. If you do not know what this license entails, please read the full license details at the following link;


The code is compiled using Java 1.4 and should work fine with all newer Java versions post 1.4.

The EPL license


Download JAR’s, source and API documentation
CVS Repository


Office 2007 Blue

Office 2005 Silver

Office 2005 Blue

Office 2005 Olive


Using the widget is easy as it is modeled after, and uses the same SWT Widgets that you may use every day. The constructor has optional extras as well, but by default the widget can be created as if it was any other SWT widget. As this widget actually changes its physical size every time a button is shown or hidden, the wrapping layout has to be one that takes advantage of a resizing widget, or the buttons widget may either behave strangely or not function properly.

The recommended spot for this widget is therefore inside the following controls:

  • SashForm
  • ViewForm
  • A Custom Composite implementation

This does not mean that the control cannot be put elsewhere, but this is the spots where I have used it and found it to work perfectly.

Normal Creation

CollapsibleButtons cButtons = new CollapsibleButtons(parent, SWT.NONE)
cButtons.addButton("Synchronize", null, ImageCache.getImage("/selection_recycle_24.png"), ImageCache.getImage("/selection_recycle_16.gif"));

Custom Composite Example

As I have a feeling many will want to put the widget in odd locations, here is some sample code on how to wrap the buttons widget. In this Example, it’s simply wrapped in an outer Composite with some special Layout flags applied:

Display display = new Display();
Shell shell = new Shell (display);
shell.setText("Buttons Widget Tester");
shell.setSize(400, 400);
shell.setLayout(new FillLayout());

Composite inner = new Composite(shell, SWT.NONE);
GridLayout gl = new GridLayout(1, true);
gl.marginBottom = 0;
gl.marginHeight = 0;
gl.marginWidth = 0;
gl.marginHeight = 0;

CollapsibleButtons cp = new CollapsibleButtons(inner, SWT.NONE, IColorManager.SKIN_OFFICE_2007);
cButtons.setLayoutData(new GridData(GridData.GRAB_VERTICAL | GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_END));
cButtons.addButton("Synchronize", null, ImageCache.getImage("/selection_recycle_24.png"), ImageCache.getImage("/selection_recycle_16.gif"));

Setting Data on Buttons and Other Widgets

Obviously you want a simple way to see what button was clicked and do something when it is clicked, and as everyone knows that has done SWT/JFace/Eclipse coding, widgets by default allow you to use the very handy setData(…) and getData(…) methods. Every item inside the Button Widget allows you to do the exact same thing, as they are all just extending Composite in the first place. So all your favorite methods are available!

When you create buttons via the ButtonComposite, you will be returned the actual button object, so if you want to set a data object on each button, for example, here’s how that’s done:

CollapsibleButtons cButtons = new CollapsibleButtons(inner, SWT.NONE);
CustomButton synch = cButtons.addButton("Synchronize", null, ImageCache.getImage("/big.png"), ImageCache.getImage("/small.gif"));
synch.setData("I am a string data object!"); 

Now the “synch” button has a data object on it, and as you will be returned the actual CustomButton for any event that happens, it’s easy to read it whenever needed.

Listening to Events

Listening to events is very easy. The IButtonListener lets you listen to clicks, hovers, and more.

cButtons.addButtonListener(new IButtonListener() {
    public void buttonClicked(CustomButton button, MouseEvent e) {
        System.out.println("You clicked me!");

    public void buttonEnter(CustomButton button, MouseEvent e) {

    public void buttonExit(CustomButton button, MouseEvent e) {

    public void buttonHover(CustomButton button, MouseEvent e) {

There is also an adapter if you don’t want to implement all the methods for each listener you are introducing. The adapter is called ButtonListenerAdapter.