Javafx Layout problem with VBox & HBoxes
Posted
by pgpatrudu
on Stack Overflow
See other posts from Stack Overflow
or by pgpatrudu
Published on 2010-05-29T09:25:30Z
Indexed on
2010/05/29
9:32 UTC
Read the original article
Hit count: 188
When I run the following, I noticed spacing between nodes; My research revealed that - 1) If I do not add any text to win1 via setwininfo, then there is no problem. 2) When I include this code in a larger app, and when a button click is reveived from some where else, mysteriously the spacing gets corrected. 3) I tried binding the win1 & win2 nodes to content of scene - but no luck.
def mainframew : Integer = 250; def mainframeh : Integer = 500;
class CtrlWindow extends CustomNode {
var wininfo : String;
var fsize : Integer;
var width : Integer;
public function setWinInfo(info : String) {
wininfo = info;
}
override protected function create () : Node {
var win = Group {
content: [
VBox {
content: [
Text {
font : Font {
size: fsize
}
content : bind wininfo
textAlignment : TextAlignment.CENTER // did not work
}
]
}
Rectangle {
width: width, height: 25
fill: Color.TRANSPARENT
strokeWidth : 2
stroke : Color.SILVER
}
]
}
return win;
}
}
public function run(args : String[]) {
var win1 = CtrlWindow{fsize:14, width:mainframew}; var win2 = CtrlWindow{fsize:14, width:mainframew};
win1.setWinInfo("The spacing between these nodes"); win2.setWinInfo("corrects itself after receiving an event");
Stage {
title : "MyApp"
scene: Scene {
width: mainframew
height: mainframeh
content: [
VBox {
spacing: 0
content: [
HBox {
content: win1
}
HBox {
content: win2
}
]
}
]
}
}
© Stack Overflow or respective owner