Ludum Dare 36
の場合、私はcoljureでテキストベースのアドベンチャーゲームを試すことにしました。それは動作しますが、私は致命的でないエラーを取得しています:java.awingをclojureにキャストすることはできませんIfn
スレッドで例外は、「メイン」とjava.lang.ClassCastException: seesaw.core.proxy $ javax.swing.JPanel $タグ$のfd407141をキャストすることはできません clojure.lang.IFnに、 コンパイル:(は/ tmp /フォームinit2500875452880490300.clj:1:73)IFNエラーがかなりよくスタック上に文書化され、私はわからないされて
(ns ludumdare36.core
(:gen-class :main true)
(:use seesaw.core))
(def story [
"Of all the most famous living rooms Transned's was the most famous"
"two"
"three"
"four"
"five"
"six"
"seven"
"eight"
"nine"
])
(def mainWindow (frame :title "Hello" :content "" :on-close :exit))
(defn draw
[items & args] (
(def mainWidget (vertical-panel :items items))
(config! mainWidget :size [640 :by 480])
(config! mainWindow :content mainWidget)
(invoke-later(-> mainWindow pack! show!))))
(defn writeStory [text index & args]
(let [makeButton (fn mb [index text]
(button :text text :mnemonic \N :halign :center :listen [:action (partial writeStory (get story index) (inc index))]))
makeStoryNode (fn ms [text index]
(vector text (makeButton (inc index) "Yes") (makeButton (+ index 2) "No")))
]
(draw (makeStoryNode text index))))
(defn -main
[& args]
(writeStory (get story 0) 0))
ました問題が原因です。また、私のコードの品質についてもわからない。だからコメントなどを投稿する自由に私はIfnのエラーを取り除くためにリファクタリングすることができますか?私は何を理解していないのですか?
行番号はコードの一部ではありません。それらを削除してください。 –
30行目で '(button ...) 'をどうすればいいですか?コードを実行する可能性がなければ、これは唯一の容疑者です。 'button'がウィジェットのラッパーである場合、そのような例外が発生します - それは頭の位置にあります。それ以外の場合は、スタックトレースと元のソースを添付してください。プロジェクトファイルも便利です。 –
クリックするとエラーが出るかもしれないと思います。だから、ボタンを戻すとIfnチェックが追加される可能性があります。 – liminal18