Clojure - Desktop Displaying Buttons


Buttons can be displayed with the help of the button class. An example on how this is used is shown in the following program.

(ns web.core
   (:require [seesaw.core :as seesaw]))
(defn -main [& args]
   (defn display
      (let [window (seesaw/frame :title "Example")]
         (-> window
            (seesaw/config! :content content)
   (def button
         :text "Click Me"
         :listen [:action (fn [event](seesaw/alert "Click!" ))]))
         (display button))

In the above code, first a button variable is created which is from the button class of the see-saw library. Next, the text of the button is set to “Click Me”. Then an event is attached to the button so that whenever the button is clicked, it will show an alert dialog box.

When the above code is run, you will get the following window.

Click Me

When you click the button, you will get the following dialog box.

Click Button