Skip to content

Instantly share code, notes, and snippets.

@daveray
Created April 5, 2012 12:44
Show Gist options
  • Save daveray/2310794 to your computer and use it in GitHub Desktop.
Save daveray/2310794 to your computer and use it in GitHub Desktop.
Highlighting table rows with Seesaw
(ns table-test.core
(:use [seesaw core table swingx]))
; A predicate that decides whether a row should be highlighted
; adapter is an instance of JXTable.TableAdapter
; http://projects.joshy.org/projects/painterreview/swingx/org/jdesktop/swingx/JXTable.TableAdapter.html
(defn hl-predicate [renderer adapter]
; Highligh all rows where :age is over thirty
(> (.getValueAt adapter (.row adapter) 0) 30))
(defn make-table []
(table-x :model [:columns [:age :height]
:rows [{:age 13 :height 45}
{:age 45 :height 13}]]
:highlighters [((hl-color :foreground :red) hl-predicate)]))
(defn -main [& args]
(invoke-later
(-> (frame :content (scrollable (make-table)))
pack!
show!)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment