Вопрос

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.

Это было полезно?

Решение

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")))
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top