无涯教程-Clojure - Desktop – Displaying Labels函数

25 阅读1分钟

可以在标签类的帮助下显示标签。以下程序显示了有关如何使用它的示例。

(ns web.core
   (:gen-class)
   (:require [seesaw.core :as seesaw]))
(defn -main [& args]
   (defn display
      [content]
      (let [window (seesaw/frame :title "Example")]
         (-> window
            (seesaw/config! :content content)
            (seesaw/pack!)
            (seesaw/show!))))
   (def label (seesaw/label
      :text "This is a label too"
      :background :white
      :foreground :black
      :font "ARIAL-BOLD-10"))
   (display label))

在上面的代码中,创建一个标签变量,该变量来自seesaw库的标签类,接下来,标签的文本设置为“This is a label too”。然后设置背景、前景色和字体。

当上面的代码运行时,您将获得以下窗口。

clojure desktop button

参考链接

www.learnfk.com/clojure/clo…