Project setup

This chapter gives an introduction how JGUIraffe is used to develop a UI-centric Java application.

The main purpose of the JGUIraffe library is to simplify development of user interfaces. Windows, panels, and dialog boxes are defined in a declarative way using a XML-dialect. In addition to creating and arranging UI components, central objects implementing application logic can be instantiated and connected with each other or elements of the user interface. The remaining part of this user's guide describes these features in detail. But before we dive into the programming of user interfaces in the JGUIraffe way, we have to say a few words about the principle setup of a project using the JGUIraffe library.

In order to make use of the features provided by this library in your own (Java-based) applications, some jars have to be added to the class path. To be more precise, two jars have to be included:

  • The main jguiraffe.jar containing central functionality and defining the specific programming model of JGUIraffe.
  • A specialized integration jar for the UI platform used by the target application.

Multiple platform support

In a JGUIraffe application manipulations of UI elements are done through interfaces like WidgetHandler, or ComponentHandler. What actually lies behind these interfaces is transparent for the application. This makes it possible to offer specialized implementations for different UI platforms. With other words: one and the same JGUIraffe application can run on different UI platforms without changes.

Currently, the following UI platforms are supported:

  • Swing
  • JavaFX
The concrete platform to be used is selected by adding the corresponding integration jar to the class path. Note that exactly one integration jar is needed; adding multiple ones for different platforms can have unpredictable effects.

Maven setup

The JGUIraffe jars are distributed to the central repository of Apache Maven. So if Maven is used as build tool, the JGUIraffe-related dependencies can be downloaded automatically. In order to simplify this setup, there is a BOM artifact defining all modules and their current versions. This artifact has to be included in the <dependencyManagement> section of your application's pom:

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>net.sf.jguiraffe</groupId>
        <artifactId>jguiraffe-bom</artifactId>
        <version>1.3</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

To declare the actual JGUIraffe dependency, it is typically sufficient to reference the integration jar for the target UI platform. This causes the dependency to JGUIraffe Core to be added in a transitive way. So for instance, if the target platform was JavaFx, the following dependency would have to be declared:

  <dependency>
    <groupId>net.sf.jguiraffe</groupId>
    <artifactId>jguiraffe-java-fx</artifactId>
  </dependency>

Note: If your application runs in an OSGi environment, refer to chapter JGUIraffe and OSGi.