Skip to main content

JavaFX Sequence Declaration

2 replies [Last post]
Joined: 2010-08-19

Hi all,
I have only just started teaching myself JavaFX, and I am struggling with a few concepts. Does anyone know how to declare a class as a sequence? I had "object holders" which were simply classes which extended ArrayLists. These had custom functions, which is why I need them in JavaFX. For example in Java:

public class MyObjectHolder extends ArrayList {</p>
<p>    public MyObjectHolder() {<br />
<p>    public void addObject(String name, Integer value) {<br />
        this.add(new MyObject(name, value));<br />

Obviously ArrayLists have been replaced with sequences, but now what?

Thanks for any help you can offer.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2007-11-15

You cannot extend sequences. Instead your MyObjectHolder can have a member, that stores the sequence. Something like this:
public class MyObjectHolder {
var mySequence: MyObject[];
public function addObject (String name, Integer value): Void {
insert MyObject {name: name, value: value} into mySequence;

> Obviously ArrayLists have been replaced with
> sequences...
No, there are different concepts involved. Roughly in JavaFX Script a simple object reference can point to zero or one instance of a class. A sequence can point to n instances of a class. A sequence is not an Object.

Joined: 2010-08-19

That's great info. Thanks very much michael_heinrichs. Been finding it hard to get good information like this.

Also, thanks for the correction on sequences not being objects. That makes a lot of sense and clears up a lot. So is there a JavaFX equivalent to an array object?