Seesaw Documentation

repository·master·Indexed 23 days ago

https://github.com/clj-commons/seesaw

A Clojure DSL for constructing user interfaces built on top of Java Swing, enabling the creation of complex UIs using functional patterns.

Tokens
771
Snippets
5
Records
6
Agent score
81%

What's inside Seesaw

  1. Run the gaidica example application

    master

    The gaidica project is an example Seesaw application that demonstrates how to display weather data from weatherunderground.com. You can run it using Leiningen by ensuring dependencies are installed and then executing the gaidica.core module.

    $ lein deps
    $ lein run -m gaidica.core
  2. Install Seesaw using Leiningen

    master

    To use Seesaw in a new project, use Leiningen to create a template and then add Seesaw as a dependency in your project.clj file.

    1. Create a new project:

      lein new hello-seesaw
      cd hello-seesaw
    2. Add Seesaw to your :dependencies in project.clj:

      (defproject hello-seesaw "1.0.0-SNAPSHOT"
        :description "FIXME: write"
        :dependencies [[org.clojure/clojure "1.4.0"]
                      [seesaw "x.y.z"]])

      Note: Replace x.y.z with the latest version of Seesaw.

    3. Run your application:

      lein run -m hello-seesaw.core
    $ lein new hello-seesaw
    $ cd hello-seesaw
  3. How to use the Seesaw bleeding edge (develop branch)

    master

    If you need to use the latest unreleased features, follow these steps:

    1. Clone the Seesaw repository and switch to the develop branch.
    2. Run lein install within the Seesaw directory to build it locally.
    3. In your own project's project.clj, set the Seesaw version to the X.Y.Z-SNAPSHOT version found in the Seesaw source.
    4. Run your project using Leiningen.
  4. Use Google Window Builder with Seesaw

    master

    This example demonstrates a workflow for designing user interfaces visually using Google Window Builder in Eclipse and then consuming those layouts within a Clojure application using Seesaw. This approach allows you to leverage Eclipse's drag-and-drop GUI designer to define forms, which can then be instantiated and manipulated via Clojure code.

    $ lein deps
    $ lein compile
    $ lein run -m window-builder.core
  5. Create a basic 'Hello World' window

    master

    To create a simple window (frame) in Seesaw, use seesaw.core functions. You should typically wrap the UI initialization in invoke-later to ensure the UI thread is ready.

    Common properties for a frame include :title, :content, and :on-close (e.g., :exit to terminate the application). After defining the frame, use pack! to size it and show! to make it visible.

    (ns hello-seesaw.core
      (:use seesaw.core))
    
    (defn -main [& args]
      (invoke-later
        (-> (frame :title "Hello",
               :content "Hello, Seesaw",
               :on-close :exit)
         pack!
         show!)))