Forum: JRuby Java method expectiong Java Interface

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Manfred U. (Guest)
on 2009-02-10 23:59
(Received via mailing list)
Hi,

I get a type error when I pass an object to a Java method which expects
an interface as parameter although the object implements this interface:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
import org.jdesktop.swingx.decorator.HighlighterFactory

test_table.setHighlighters( HighlighterFactory.createSimpleStriping() )

==>

TypeError - for method setHighlighters expected
[[Lorg.jdesktop.swingx.decorator.Highlighter;]; got:
[org.jdesktop.swingx.decorator.HighlighterFactory$UIColorHighlighter];
error: argument type mismatch
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Thanks,
Manfred

--
Manfred U.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Manfred U. (Guest)
on 2009-02-11 17:23
(Received via mailing list)
On Tue, 10 Feb 2009 22:58:21 +0100
Manfred U. <removed_email_address@domain.invalid> wrote:

> () )
>
> ==>
>
> TypeError - for method setHighlighters expected
> [[Lorg.jdesktop.swingx.decorator.Highlighter;]; got:
> [org.jdesktop.swingx.decorator.HighlighterFactory
> $UIColorHighlighter]; error: argument type mismatch
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Although this works as is in Java, I overlooked that actually a list is
expected.

Changing the line to

test_table.set_highlighters(
[HighlighterFactory.create_simple_striping()].to_java(Highlighter) )

fixed it.

Manfred


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.