Tim Martin wrote: > Hi all, > ... > The JDialog contructor takes a parameter that will tell it to be a modal window.
(ns cara.gui.dialog-test (:import [javax.swing JDialog JTextField JButton AbstractAction])) (defn- create-and-show [data-ref] (let [dialog (new JDialog (@data-ref :owner) true) ;;second parameter says block on setVisible text-field (doto (new JTextField) (.setColumns 40) (.setText (@data-ref :text))) ok-btn (doto (new JButton "OK") (.addActionListener (proxy [AbstractAction] [] (actionPerformed [evt] (dosync (alter data-ref assoc :text (.getText text-field))) (.dispose dialog)))))] (doto dialog (.setLayout (new java.awt.FlowLayout)) (.add text-field) (.add ok-btn) (.pack) (.setVisible true)) (@data-ref :text))) (defn user-string [owner base-string] (create-and-show (ref {:owner owner :text base-string}))) cara.gui.dialog-test=> (user-string nil "hallo world") ;; a dialog shows up, i change the text then press ok "hello world" cara.gui.dialog-test=> I don't like this very much as there's mutable state in the data-ref, but it does the job. If someone else have a better idea, let me know! hth, Sacha --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---