Created
March 19, 2011 23:13
-
-
Save raek/877894 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 _] | |
(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) | |
(defn init-renderer [this] | |
(.setOpaque this true)) | |
(def list-cell-renderer | |
(doto (-> (get-proxy-class JLabel ListCellRenderer) | |
(construct-proxy)) | |
(init-proxy {"getListCellRendererComponent" #'prepare-renderer}) | |
(init-renderer))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment