Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: for the plan.

Jump to: navigation, search

Nebula SwitchButton

Revision as of 08:09, 19 March 2020 by Unnamed Poltroon (Talk) (Usage)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

< Back to Nebula Main Page



This is a switch button to pick one value.


A switch button is a different graphic representation of a checkbox button. So the API is similar to the Button widget. You can get or set the selection,add selection listeners, enable or disable the button...

final SwitchButton button = new SwitchButton(shell, SWT.NONE);
button.setText("Switch button...");
button.addListener(SWT.Selection, e-> {
    System.out.println("Before clicking, the selection was... " + button.getSelection());


By default, the button is grey, without border, with a blue background and 2 labels "On" and "Off". You can customize almost all elements of a switch button by setting the following properties :

  • textForSelect: text associated to the selected state of the button
  • textForUnselect: text associated to the unselected state of the button
  • text: text displayed besides the button
  • round: if true, the switch button's corners are round. If false, the switch button's corners are square.
  • borderColor: if set, a border is displayed around the widget.
  • focusColor: Color of the button when the focus is on.
  • selectedForegroundColor and selectedBackgroundColor: Color of the button (text color and background color) of the selected state of the button.
  • unselectedForegroundColor and <code>unselectedBackgroundColor: : text associated to the select state of the button
  • buttonBorderColor, buttonBackgroundColor1 and buttonBackgroundColor1: Colors of the button (border and gradient)
  • gap: gap between the button and the associated text
  • foreground, background: foreground and background colors of the whole widget.
  • font: font of the widget


An example called SwitchButtonSnippet is available in the directory org.eclipse.nebula.widgets.opal.switchbutton.snippets.

This example is also available here :

Back to the top