-
-
Save lildata/c9e4041ee8f0ebe6760f to your computer and use it in GitHub Desktop.
Highlighting table rows with Seesaw
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
(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