Created
April 29, 2012 18:07
-
-
Save mistercam/2552324 to your computer and use it in GitHub Desktop.
Function that starts a Swing-based Reversi game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn reversi-swing [] | |
"Starts a Swing-based Reversi game." | |
(let [board (atom (initialize-board)) ; the active board (mutable) | |
piece (atom :b) ; the active piece (mutable) | |
frame (JFrame. "Reversi") ; the outer Swing container. "Reversi" appears in the title bar. | |
panel (reversi-panel frame board piece)] ; the Reversi board | |
(doto panel | |
(.setFocusable true) ; focus can be given to this panel | |
(.addMouseListener panel)) ; have the panel listen for mouse events | |
(doto frame | |
(.add panel) ; add our Reversi panel to the frame | |
(.pack) ; size the frame to fit the preferred size of our panel | |
(.setVisible true)))) ; make the frame visible |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment