2

is there any way i can get the values of a Listbox in seesaw as a collection, that Clojure can handle?

The most i've got was a JList, which Clojure can't handle.

/edit: To Clarify: For Example i want to get all of the Elements of a Listbox and conj a new Element onto them. But Because the return value of the listbox is a JList, Clojure naturally can't do that.

I can't seem to find any method to extract all Elements from the listbox.

WeGi
  • 1,908
  • 1
  • 21
  • 33
  • What do you mean by "can't handle"? There should be no functionality you cannot access using the proper interop methods (ie. `(.getModel jl)`) – noisesmith Feb 18 '14 at 17:18
  • I added an example for clarity. – WeGi Feb 18 '14 at 17:57
  • 1
    the JList docs mention that the list should not be modified - you would want to empty it and recreate the list anyway, even in Java – noisesmith Feb 18 '14 at 18:12

1 Answers1

4

See this. You can use getModel method to get ListModel. And then use getElementAt and getSize method to build array or list or whatever you want.

(def data (into-array String ["one" "two" "three" "four"]))
(def myList (JList. data))
(->> myList 
    .getModel 
    ((juxt identity (memfn getSize))) 
    ((fn [[a b]] (map #(.getElementAt a %) (range b)))) 
    (apply vector) (#(conj % "five")))
Community
  • 1
  • 1
KobbyPemson
  • 2,519
  • 1
  • 18
  • 33