Skip to content

Instantly share code, notes, and snippets.

@kamchy
Created March 27, 2017 04:24
Show Gist options
  • Save kamchy/ce0024b5a8beffdce3b206ef8fcbd854 to your computer and use it in GitHub Desktop.
Save kamchy/ce0024b5a8beffdce3b206ef8fcbd854 to your computer and use it in GitHub Desktop.
(ns seesaw-creds.core
(:use [seesaw.core])
(:require [seesaw.forms :as f])
(:require [seesaw.border :as b])
(:require [seesaw.bind :as bi])
(:require [seesaw.mig :as m])
(:require [seesaw.color :as c])
(:gen-class))
(defn generate[ev atm tf]
(config! tf :text (clojure.string/join "\n " (map #(deref (% atm)) [:login :from :to :pass]))))
(defn mk-pane [a]
"Specification:
http://manual.openestate.org/extern/forms-1.2.1/whitepaper.pdf"
(with-widgets [
(text :id :idlogin :text (or @(:login a) ""))
(text :id :idfrom :text (or @(:from a) ""))
(password :id :idpass)
(text :id :idto :text (or @(:to a) ""))
(button :text "Generate" :id :button-generate )
(text
:id :idarea
:multi-line? true
:rows 10
:text "empty"
;;:border (b/line-border :color (c/color "#000") :thickness 1)
)
]
(bi/bind (.getDocument idlogin) (:login a))
(bi/bind (.getDocument idfrom) (:from a))
(bi/bind (.getDocument idto) (:to a))
(bi/bind (.getDocument idpass) (:pass a))
(config! button-generate
:action (action :handler #(generate % a idarea) :name "Generate" :mnemonic \G))
(f/forms-panel
"right:pref, 3dlu, 50dlu, 3dlu,
right:pref, 3dlu, 50dlu, default
"
:default-dialog-border? true
:items [
"&Login" idlogin
"&From" idfrom
"&Password" idpass
"&To" idto
button-generate (f/next-line)
(f/span (scrollable idarea) 8)])))
(defn mk-frame [atm]
(let [content-pane (mk-pane atm)]
(-> (frame :title "Hello"
:content content-pane
:size [640 :by 480]
)
pack!
show!
)))
(defn -main
[& args]
(let [atm {:login (atom "k") :from (atom "2016") :to (atom "34") :pass (atom "")}]
(invoke-later (mk-frame atm))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment