Skip to main content

Calling a Java method that returns a string array...

2 replies [Last post]
Joined: 2006-03-06

I have a Java class with a public method that returns an array of string values:

public String[] getFoo();

How can I get the string values into a JavaFX String array:

var foos:String*;
// Assign values from getFoo method to foos variable?

As an alternative, I tried a Java method which took an array index and returned
a single string from the array.

public String getFoo(int index);

var temp:String;
var foos:String*;
foos = [];
foreach (i in [0..4]) {
temp = instance.getFoo(i.intValue());
insert temp as last into foos;

This, of course, does not work as the type "i.intValue()" is still a BigInteger.
So, how do I coerce the JavaFx variable "i" into a Java "int" to use as
a parameter in the Java method call?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2004-07-02

User Array.asList() to convert the array to a List, then iterate over it and insert each element into the JavaFX sequence. Ugly, but it works.

Joined: 2007-05-18

This is a known issue (see JIRA JFXC-555, and is slated to be addressed in the Milestone 3 release if not sooner.

Jim Weaver