Reputation: 11
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
}
]
}
]
}
}
Upvotes: 1
Views: 1312
Reputation: 1409
Assuming you are using JavaFX 1.3, the issue may be related to the preferred sizes of the CtrlWindow. You may want to use a layoutInfo to set a common preferred size, otherwise, the preferred size will change with the content of the two CtrlWindow nodes.
Something like:
win1 = CtrlWindow{
fsize:14
layoutInfo : LayoutInfo { width: mainframew, minHeight: 50 }
}
When you merely set the width (without a bind), this will be reset to the preferred size in the HBox layout.
Upvotes: 1