> It did get me thinking that it would be great to have a way to
> interrogate an open gui app from the command line, or perhaps, from a
> separate area in the app itself (say, a special "debugging" tab in the
> main window). Having a standard way to alter the app while it's
> running would be some kind of wonderful. If anyone has any ideas on
> that I'd love to hear them.
Indeed you can do all those things using a REPL.You can interactively
do pretty much anything. You could even embed a REPL into your
application with a socket back-door, connect to it and really have fun
with your users.
Here is a semi-practical example (copy these into your REPL one at a
time):
(defn add-button
"Create a JButton and add it to a Container with an ActionListener"
[#^java.awt.Container container, #^String button-label, function]
(.add container (doto (javax.swing.JButton. button-label)
(.addActionListener
(proxy [java.awt.event.ActionListener] []
(actionPerformed [evt] (function evt)))))))
(defn later [function]
(java.awt.EventQueue/invokeLater function))
(def frame (javax.swing.JFrame. "inter-app"))
(later #(.setVisible frame true))
(later #(add-button frame "greeter" (fn [evt] (println "hello" evt))))
(later #(.pack frame))
(later #(.dispose frame))
Regards,
Tim.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---