Open Source JavaFX Now!
Combination View Flat View Tree View
Layout problem
toggle
Layout problem
miglayout
11/6/09 10:21 AM
Good day!
I have the next problem with Layout in the my UI application.
I'm using MigLayout. And when I'm putting inside this layout Custom Node it doesn't fill the whole area (after resizing too).
(for easy understand I'm taking you text-example with dock layout with trying insert into it my CustomNode with heigh 90px, but my custom node doesn't take 90px height)

Stage {
title: "Mig Docking Test"
scene: ResizableScene {
width: 400
height: 400
fill: Color.LEMONCHIFFON
content:
ResizableVBox{
content:
MigLayout {
constraints: "fill"
content: [
migNode( MyCustomNode{}, "north"),
migNode( createLabel( Color.GOLDENROD, "Center" ), "center, grow" ),
]

}
}
}
}

/**
* My custom Node
*/
class MyCustomNode extends CustomNode {
var rec:Rectangle = Rectangle{
width: 40, height: 40
fill: Color.BLACK
}
var text:Text = Text{
font : Font {
size: 24
}
content: "HelloWorld"
}

public override function create(): Node {
return MigLayout {
//layoutInfo: nodeConstraints( "pos 0 0 container.x2 container.y2" )
constraints: "fill, h 90:90"
content: [
migNode( rec, "west" ),
migNode( text, "east, grow" ),
]
}
}
}

/**
* Method for create center element
*/
function createLabel( color:Color, label:String ) {
var text:Text =Text {
id: "text:{label}"
content: label
font: Font { size: 18 }
layoutInfo: nodeConstraints( "center, grow" )
}
MigLayout {
id: label
constraints: "fill"
content: [
ResizableRectangle {
fill: Color.BROWN
layoutInfo: nodeConstraints( "pos 0 0 container.x2 container.y2" )
},
migNode( text, "center" )
]
}
}
Flag Flag
RE: Layout problem
12/7/09 8:41 PM as a reply to irina ira Mir.
If you want your CustomNode to be 90 pixels high, you need to specify that in the node constraints when you add it to MigLayout.

 1
 2Stage {
 3   title: "Mig Docking Test"
 4   scene: XScene {
 5       width: 400
 6       height: 400
 7       fill: Color.LEMONCHIFFON
 8       content: XVBox{
 9           content:
10           MigLayout {
11               constraints: "fill"
12               content: [
13                   migNode( MyCustomNode{}, "north, h 90!"),
14                   migNode( createLabel( Color.GOLDENROD, "Center" ), "center, grow" ),
15               ]
16           }
17       }
18   }
19}


This still won't cause your CustomNode to fill the area, though. CustomNodes are not Resizable.

Dean
Flag Flag