jruby,如何将2d ruby​​数组传递给java方法

时间:2013-09-13 03:35:37

标签: jruby

使用Jruby并希望将2d ruby​​数组传递给javax.swing.table.DefaultTableModel

#create a empty table view on UI and will fill out it later
columns = ['1','2']
data = [[]]
columns.length.times{ data.first << ""}
# below raise exception
mode = javax.swing.table.DefaultTableModel.new(data,columns)

似乎是方法签名匹配引起的异常,如何解决呢?

NameError: no constructorfor arguments (org.jruby.java.proxies.ArrayJavaProxy
,or g.jruby.RubyArray) on Java::JavaxSwingTable::DefaultTableModel
available overloads:
(java.util.Vector,java.util.Vector)
(java.lang.Object[],int)
(java.util.Vector,int)
(int,int)
(java.lang.Object[][],java.lang.Object[])

1 个答案:

答案 0 :(得分:0)

从Ruby值填充Java Vector ...

 matrix = java.util.Vector.new
 datos.each do |valor|   
      matrix.add_element(valor)
 end #datos.each do |valor|   

我在应用程序上使用Swing ...

http://sourceforge.net/projects/rmldonkey/

Regads