I tried to build a Swing gui with Clojure and get an error I don't
understand. Perhaps it's more a swing-problem than a clojure-problem,
but I'm sure the solution is simple and someone here will know the
answer.
I have two frames, one serves as the main-window of the app and the
second one opens if a button is clicked. The purpose of the second one
is to give some status messages to the user while performing a complex
operation.
My problem is: I want to change a component (textbox or label) between
two function calls, but it doesn't work! When the second frame is
opened, it remains grey until all operations are finished. I built a
simple example to show the problem:
(ns guitest)
(import '(javax.swing JFrame JLabel JTextField JButton)
'(java.awt.event ActionListener)
'(java.awt GridLayout))
(defn complex-calc []
(Thread/sleep 2000)
(Math/random ))
(defn testgui []
(let [frame (JFrame. "Test")
frame2 (JFrame. "Testwin")
temp-text (JTextField.)
convert-button (JButton. "Click!")]
(doto frame
(.setLayout (GridLayout. 1 1 1 1))
(.add convert-button)
(.setSize 100 100)
(.setVisible true))
(doto frame2
(.setLayout (GridLayout. 1 1 1 1))
(.add temp-text)
(.setSize 100 100))
(.addActionListener convert-button
(proxy [ActionListener] []
(actionPerformed [evt]
(.show frame2)
(complex-calc)
(.setText temp-text "Calc1")
(complex-calc)
(.setText temp-text "Calc2")
(complex-calc)
(.setText temp-text "Calc3"))))))
(testgui)
In this example (.setText temp-text "...") shows no effect. What have
I done wrong?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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