From 3523aeb4c76c2ecdde88a37e484d87e833bd9013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Wieche=C4=87?= Date: Tue, 28 Mar 2023 17:35:00 +0200 Subject: [PATCH] initial adding simple example for radiance libs refs #233 --- examples/radiance/.nrepl-port | 1 + examples/radiance/README.md | 16 ++++++ examples/radiance/project.clj | 7 +++ examples/radiance/src/radiance/core.clj | 73 +++++++++++++++++++++++++ 4 files changed, 97 insertions(+) create mode 100644 examples/radiance/.nrepl-port create mode 100644 examples/radiance/README.md create mode 100644 examples/radiance/project.clj create mode 100644 examples/radiance/src/radiance/core.clj diff --git a/examples/radiance/.nrepl-port b/examples/radiance/.nrepl-port new file mode 100644 index 00000000..df48661f --- /dev/null +++ b/examples/radiance/.nrepl-port @@ -0,0 +1 @@ +44297 \ No newline at end of file diff --git a/examples/radiance/README.md b/examples/radiance/README.md new file mode 100644 index 00000000..d1d7785e --- /dev/null +++ b/examples/radiance/README.md @@ -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. diff --git a/examples/radiance/project.clj b/examples/radiance/project.clj new file mode 100644 index 00000000..fe8fcfae --- /dev/null +++ b/examples/radiance/project.clj @@ -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) diff --git a/examples/radiance/src/radiance/core.clj b/examples/radiance/src/radiance/core.clj new file mode 100644 index 00000000..000dc0dd --- /dev/null +++ b/examples/radiance/src/radiance/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 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= + + Call (javax.swing.UIManager/setLookAndFeel \"\") + 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!)))