Skip to content
Browse files

Added a standalone example of using substance look and feel

  • Loading branch information...
1 parent c34a0c9 commit 599117020999245557e98792cc3364d720c48b71 @daveray committed Mar 10, 2012
View
2 examples/README.md
@@ -1,5 +1,5 @@
# Seesaw Examples
-These are Seesaw example projects. They're here because they have external dependencies that I don't want in the main Seesaw project.
+These are Seesaw example projects. They're here because they have external dependencies that I don't want in the main Seesaw project.
The main body of Seesaw examples can be found in `../test/seesaw/test/examples`.
View
2 examples/gaidica/README.md
@@ -9,6 +9,6 @@ Example Seesaw application. Display weather data from weatherunderground.com
## License
-Copyright (C) 2010 FIXME
+Copyright (C) 2012 Dave Ray
Distributed under the Eclipse Public License, the same as Clojure.
View
16 examples/substance/README.md
@@ -0,0 +1,16 @@
+# substance
+
+This is an example of how to use Substance look and feels with Seesaw. There's really nothing to it, but since it's a little Java-y, it's nice to have a working example in Clojure.
+
+Run the example, or see src/substance/core.clj for details.
+
+## Usage
+
+ $ lein deps
+ $ lein run
+
+## License
+
+Copyright (C) 2012 Dave Ray
+
+Distributed under the Eclipse Public License, the same as Clojure.
View
7 examples/substance/project.clj
@@ -0,0 +1,7 @@
+(defproject substance "1.0.0-SNAPSHOT"
+ :description "Example of using Substance Look and Feel with Seesaw"
+ :dependencies [[org.clojure/clojure "1.3.0"]
+ [seesaw "1.4.0"]
+ [com.github.insubstantial/substance "7.1"]]
+ :main substance.core)
+
View
73 examples/substance/src/substance/core.clj
@@ -0,0 +1,73 @@
+; Copyright (c) Dave Ray, 2012. All rights reserved.
+
+; The use and distribution terms for this software are covered by the
+; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
+; which can be found in the file epl-v10.html at the root of this
+; distribution.
+; By using this software in any fashion, you are agreeing to be bound by
+; the terms of this license.
+; You must not remove this notice, or any other, from this software.
+
+(ns substance.core
+ (:use [seesaw.core])
+ (:import org.pushingpixels.substance.api.SubstanceLookAndFeel)
+ (:gen-class))
+
+(defn laf-selector []
+ (horizontal-panel
+ :items ["Substance skin: "
+ (combobox
+ :model (vals (SubstanceLookAndFeel/getAllSkins))
+ :renderer (fn [this {:keys [value]}]
+ (text! this (.getClassName value)))
+ :listen [:selection (fn [e]
+ ; Invoke later because CB doens't like changing L&F while
+ ; it's doing stuff.
+ (invoke-later
+ (-> e
+ selection
+ .getClassName
+ SubstanceLookAndFeel/setSkin)))])]))
+
+(def notes " This example shows the available Substance skins. Substance
+is a set of improved look and feels for Swing. To use it in a project,
+you'll need to add a dep to your Leiningen project:
+
+ [com.github.insubstantial/substance \"7.1\"]
+
+In this example, the full class name of the current skin is shown the
+in the combobox above. For your own apps you could either use a
+selector like this example, or, more likely, set a default initial
+skin in one of the following ways:
+
+ Start your VM with -Dswing.defaultlaf=<class-name>
+
+ Call (javax.swing.UIManager/setLookAndFeel \"<class-name>\")
+ do this *after* (seesaw.core/native!) since that sets the L&F.
+
+See http://insubstantial.github.com/insubstantial/substance/docs/getting-started.html
+for more info. There you'll also find much more info about the
+skins along with much less crappy looking demos.")
+
+(defn -main [& args]
+ (invoke-later
+ (->
+ (frame
+ :title "Seesaw Substance/Insubstantial Example"
+ :on-close :exit
+ :content (vertical-panel
+ :items [(laf-selector)
+ (text :multi-line? true :text notes :border 5)
+ :separator
+ (label :text "A Label")
+ (button :text "A Button")
+ (checkbox :text "A checkbox")
+ (combobox :model ["A combobox" "more" "items"])
+ (horizontal-panel
+ :border "Some radio buttons"
+ :items (map (partial radio :text)
+ ["First" "Second" "Third"]))
+ (scrollable (listbox :model (range 100)))]))
+ pack!
+ show!)))
+

0 comments on commit 5991170

Please sign in to comment.
Something went wrong with that request. Please try again.