I’m working on a Java project making use of SWT where I wanted a nice user interface for the configuration panel: something modern and nice looking. I was inspired by the simple design of Gnome 3.

SWT widget does not provide a switch button out of the box. Various projects are proposing a switch button and I’ve tried many of them without falling in love with any. The best one is proposed by Opal project, but it misses some feature and had drawing issue in some edges cases.

I’ve fork the widget to propose my own version.

Preview

See how it looks.

  • Preview in Windows XP
  • Preview in Windows 7
  • Preview in Gnome 3 (GTK2)

Code

The code is available on github.

You may used it in your maven project as follow:

<repositories>
    <repository>
        <id>patrikdufresne</id>
        <url>http://nexus.patrikdufresne.com/content/repositories/public/</url>
    </repository>
</repositories>
...
<dependency>
    <groupId>com.patrikdufresne</groupId>
    <artifactId>com.patrikdufresne.switchbutton</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency>