Created
March 10, 2011 21:16
-
-
Save raek/864942 to your computer and use it in GitHub Desktop.
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 prepare-renderer [this list item _ selected _] | |
(.setOpaque this true) | |
(let [[bg fg] (if selected | |
[#(.getSelectionBackground %) | |
#(.getSelectionForeground %)] | |
[#(.getBackground %) | |
#(.getForeground %)])] | |
(.setBackground this (bg list)) | |
(.setForeground this (fg list))) | |
(let [[item-type display-string _ _ _] item] | |
(.setIcon this (-> item-type item-type-names icons)) | |
(.setFont this monospace-font) | |
(.setText this display-string)) | |
this) | |
(def list-cell-renderer | |
(doto (-> (get-proxy-class JLabel ListCellRenderer) | |
(construct-proxy)) | |
(init-proxy {"getListCellRendererComponent" prepare-renderer}))) |
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
(def list-cell-renderer | |
(proxy [JLabel ListCellRenderer] [] | |
(getListCellRendererComponent [list item _ selected _] | |
(.setOpaque this true) | |
(let [[bg fg] (if selected | |
[#(.getSelectionBackground %) | |
#(.getSelectionForeground %)] | |
[#(.getBackground %) | |
#(.getForeground %)])] | |
(.setBackground this (bg list)) | |
(.setForeground this (fg list))) | |
(let [[item-type display-string _ _ _] item] | |
(.setIcon this (-> item-type item-type-names icons)) | |
(.setFont this monospace-font) | |
(.setText this display-string)) | |
this))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment