Skip to main content

Box and VerticalGlue

3 replies [Last post]
makados
Offline
Joined: 2006-06-20
Points: 0

I need analog of next code on Swing

<br />
Box b = Box.createVerticalBox();<br />
b.add(;<br />
b.add(Box.createVerticalGlue());<br />

So I've written such code:

<br />
Box {<br />
        orientation: VERTICAL<br />
        //content: bind this.contacts<br />
        content: [<br />
            Contact {name: "111"},<br />
            Contact{name: "222"},<br />
            VerticalGlue{}<br />
        ]<br />
    }<br />

but, unfortunately, it doesn't work. Who can help with this VerticalGlue or tell me component instead?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
shagus
Offline
Joined: 2007-05-10
Points: 0

Hi, you can put only UI component in the Box.
Here is the slightly changed version of your code:

import javafx.ui.*;

public class Contact {
attribute name:String;
}
var contacts = [Contact{name: "111"}, Contact{name: "222"} ];
Frame { content:
Box {
orientation: Orientation.VERTICAL
content: [ for (i in [0 .. (sizeof contacts - 1)] ) { Label { text: bind contacts[i].name } } ]
}
visible:true
}

shagus
Offline
Joined: 2007-05-10
Points: 0

Sorry.
Instead of text: bind contacts.name
it should be text: bind contacts[i].name

shagus
Offline
Joined: 2007-05-10
Points: 0

With "i" it doesn't work. Try the following:

import javafx.ui.*;

public class Contact {
attribute name:String;
}
var contacts = [Contact{name: "111"}, Contact{name: "222"} ];
Frame { content:
Box {
orientation: Orientation.VERTICAL
content: [ for (k in [0 .. (sizeof contacts - 1)] ) { Label { text: bind contacts[k].name } } ]
}
visible:true
}