Java method expectiong Java Interface


#1

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

#2

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