Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
adding simple example for radiance libs

refs clj-commons#233
  • Loading branch information
lwiechec committed Mar 28, 2023
1 parent 7dbc738 commit 3523aeb
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/radiance/.nrepl-port
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
44297
16 changes: 16 additions & 0 deletions examples/radiance/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# radiance

This is an example of how to use Radiance 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/radiance/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.
7 changes: 7 additions & 0 deletions examples/radiance/project.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(defproject radiance "1.0.0-SNAPSHOT"
:description "Example of using Radiance Look and Feel with Seesaw"
:dependencies [[org.clojure/clojure "1.11.1"]
[seesaw "1.5.0"]
[org.pushing-pixels/radiance-common "6.5.0"]
[org.pushing-pixels/radiance-theming "6.5.0"]]
:main radiance.core)
73 changes: 73 additions & 0 deletions examples/radiance/src/radiance/core.clj
Original file line number Diff line number Diff line change
@@ -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 radiance.core
(:use [seesaw.core])
(:import org.pushingpixels.radiance.theming.api.RadianceThemingCortex$GlobalScope)
(:gen-class))

(defn laf-selector []
(horizontal-panel
:items ["Radiance skin: "
(combobox
:model (vals (RadianceThemingCortex$GlobalScope/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
RadianceThemingCortex$GlobalScope/setSkin)))])]))

(def notes " This example shows the available Radiance 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:
[org.pushing-pixels/radiance-common \"6.5.0\"]
[org.pushing-pixels/radiance-theming \"6.5.0\"]
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 https://github.com/kirill-grouchnikov/radiance
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 kirill-grouchnikov/radiance 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 3523aeb

Please sign in to comment.