Skip to content

Instantly share code, notes, and snippets.

@raek
Created March 19, 2011 23:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raek/877894 to your computer and use it in GitHub Desktop.
Save raek/877894 to your computer and use it in GitHub Desktop.
(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