Photo credit: Bath Master

With growing demand for web application, we see a lot of new technologies to meet that need: Bootstrap, node.js, Vaddin, Fontello, etc. Today, I try to bring some of this technology to desktop application development. Yes, it still exists!

I developed a library to easily use Font Awesome icons in SWT desktop application. If you do not already know Font Awesome, it’s a collection of icons, available as a font and widely used for web applications.

I tested it works on Linux, Windows XP and Windows 7.

See for yourself the collection of icons available:

Collection of icons

In a Maven project, it is possible for you to use this library by adding the following code to your pom.xml:


<repositories>
    <repository>
        <id>patrikdufresne</id>
        <url>http://nexus.patrikdufresne.com/content/groups/public/</url>
    </repository>
</repositories>
[...]
<dependency>
    <groupId>com.patrikdufresne</groupId>
    <artifactId>com.patrikdufresne.fontawesome</artifactId>
    <version>4.3.0-1</version>
</dependency>

In your Java project, it is possible to use an icon as follows:


Label text = new Label(shell, SWT.NONE);
text.setFont(FontAwesome.getFont(22));
text.setText(FontAwesome.times);

Since Font Awesome is a font, you can use it almost anywhere! I’ve not tested it on all platforms, but it seems possible to mix Font Awesome characters with standard characters.

Examples of use in SWT