Skip to main content

Conversion of Java Generics to JavaFX sequence in Java Program

2 replies [Last post]
Joined: 2009-04-18

I have created a which collects the latest 20 tweets and generates a List
I know that I have to convert this Java List into a JavaFX Sequence using Sequences.
Have tried quite a few variations with Sequences.make(...) but to no avail.

following is the code:
import com.sun.javafx.runtime.sequence.Sequence;
import com.sun.javafx.runtime.sequence.Sequences;
import java.util.Iterator;
import org.w3c.dom.TypeInfo;...
List ltu = new ArrayList();
TwitterUpdate tu = new TwitterUpdate();
Sequence<? extends TwitterUpdate> stu;
public Sequence getUpdates()
for (Status status : api.getFriendsTimeline())

//convert the List to a Sequence
//return the sequence

Am I missing a step or two or doing something completed wrong.??
I really have to get this done..

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2009-04-18

We are actually following MVC architecture, where in our back end is totally in Java and the rendering is handled in JavaFX..
Hence interop between the two was extremely important..
and the problem was that...
in our JavaFX project...we have packages with only java files and other packages with only JavaFX package..
So whilst importing packages in a JavaFX classes..we can recognize our own java and javafx files...
But whilst in Java classes..recognition of Javafx packages is not possible....
Hence sharing Data structures between the two was difficult...
So we ended up making POJOs..and ported that in JavaFX classes as it was able to recognize Java objects...
We are now using concept of Array of objects and passing it to JavaFX classes as return type..


Joined: 2003-06-12

That last line really helped:
"We are now using concept of Array of objects and passing it to JavaFX classes as return type..."


Call to Java object metricCalculator, that returns a bunch of HeatAtInterval, where HeatAtInterval is also a Java object:
def objArray: Object[] = metricCalculator.collectDataForGraph();
Can be directly converted to JavaFX sequence:
objArray as HeatAtInterval[]

In collectDataForGraph() (which is Java code):
public Object[] collectDataForGraph( SporadicList.ErrorOn errorOn)
List result = new ArrayList();
return result.toArray();