Hi-- I'm trying to write a GUI-based Java program from within Clojure, and I'm using an interesting library called Piccolo2D (http:// www.piccolo2d.org). The worldwide intersection of Clojure and Piccolo2D is probably *me*, but I'm hoping that someone here can point me in the right direction.
I'm starting by trying to translate an existing Hello World program into its Clojure equivalent: ------------------------------------------------ import javax.swing.JFrame; import edu.umd.cs.piccolo.PCanvas; import edu.umd.cs.piccolo.nodes.PText; public class HelloWorldExample extends JFrame { private HelloWorldExample() { final PCanvas canvas = new PCanvas(); final PText text = new PText("Hello World"); canvas.getLayer().addChild(text); add(canvas); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(600, 400); setVisible(true); } public static void main(String[] args) { new HelloWorldExample(); } } ------------------------------------------------------ Here's my best attempt so far: ------------------------------------------------------ (ns piccoloHello (:gen-class) (:import (edu.umd.cs.piccolo PCanvas PNode PLayer) (edu.umd.cs.piccolo.nodes PText) (edu.umd.cs.piccolox PFrame))) (defn create-frame "Creates the main PFrame used by the program." [] (proxy [PFrame] [] (initialize [] (let [aCanvas (PCanvas.) aFrame (PFrame. "Piccolo2D Hello World" false aCanvas) aNode (PText. "Hello World") aLayer (.getLayer aCanvas)] (. aLayer .addChild aNode))))) (defn -main [] (let [main-frame (create-frame)] (.setVisible main-frame true))) -------------------------------------------------------- Running it displays a window with "Piccolo2D Hello World" in the title bar, but no text in the window's canvas. The program exits with the following error message: >>>>> Exception in thread "AWT-EventQueue-0" >>>>> java.lang.IllegalArgumentException: No matching method found: .addChild >>>>> for class edu.umd.cs.piccolo.PLayer BTW, you probably should know that PCanvas is a subclass of JComponent, that PLayer and PText are subclasses of PNode, and that PLayer does not have an addChild method, but that PNode does. POSSIBLE CAUSES: One, it's probable that I don't know what I'm doing and I have the wrong syntax for using proxy to subclass PFrame. Two, my suspicion is I need to do something special to invoke PNode's addChild method on aLayer, and I don't know what that is. I found proxy-super as a Clojure function, but I couldn't find a way to use it that helped. Any educated guesses? Thanks. -- 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 Note that posts from new members are moderated - please be patient with your first post. 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 To unsubscribe, reply using "remove me" as the subject.