I'm working through "The Joy of Clojure" and got to a section about displaying some graphics in a window. My interaction with the REPL is below. According to the book, this should make a small window appear. A window does not appear.
I'm running Mac OS X Mavericks.
nREPL server started on port 54014 on host 127.0.0.1 - nrepl://127.0.0.1:54014
REPL-y 0.3.1
Clojure 1.6.0
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e
user=> (def frame (java.awt.Frame.))
#'user/frame
user=> (.setVisible frame true)
nil
user=> (.setSize frame (java.awt.Dimension. 200 200))
nil
user=> frame
#<Frame java.awt.Frame[frame0,0,22,200x200,layout=java.awt.BorderLayout,title=,resizable,normal]>
user=>
The frame does launch, but it may not be very noticable since it will be a small empty frame when the forms that you specified are executed.
You should increase the size of the frame and then draw something conspicuous, eg:
(def frame (java.awt.Frame.))
(.setVisible frame true)
(.setSize frame (java.awt.Dimension. 400 400))
(def gfx (.getGraphics frame))
(.setColor gfx (java.awt.Color/GREEN))
(.fillOval gfx 100 100 200 300)
(.toFront frame)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.