On Nov 16, 2010, at 5:49 PM, unst...@gmail.com wrote:

> This seems like such an obvious question, but I can't seem to find the
> answer anywhere. I don't understand why this would not be included in
> the java_interop section of the clojure documentation.
> 
> Is it possible to pass a clojure vector to a java function that
> requires a java vector as an argument? Apparently not since:
> 
> (javax.swing.table.DefaultTableModel. ["I" "B"] 0) fails.
> 
> What is the idiomatic way to do this?
> 

It looks as though your constructor takes either a java.util.Vector or an array 
of Object[].

To make a String[] array out of a Clojure vector 
(clojure.lang.PersistentVector):
(into-array String ["I" "B"])

So you wind up with this:
(javax.swing.table.DefaultTableModel. (into-array String ["I" "B"]) 0)
#<DefaultTableModel javax.swing.table.defaulttablemo...@3ebc312f>

Have all good days,
David Sletten




-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to