Clojure-desktop-displaying-text-fields

提供:Dev Guides
移動先:案内検索

Clojure-デスクトップのテキストフィールドの表示

テキストフィールドは、テキストクラスを使用して表示できます。 これがどのように使用されるかの例は、次のプログラムに示されています。

(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 textfield
      (seesaw/text
         :text "This is a text field"
         :editable? false
         :columns 50))
   (display textfield))

上記のコードでは、最初にシーソーライブラリのテキストクラスからのテキストフィールド変数が作成されます。 次に、テキストフィールドのテキストが「これはテキストフィールドです」に設定されます。 次に、編集可能属性をfalseに設定して、テキストフィールドを静的フィールドにします。

上記のコードを実行すると、次のウィンドウが表示されます。

テキストフィールド