MigLayout component dynamic sizing question

208 views
Skip to first unread message

pbl...@hotmail.com

unread,
May 13, 2009, 12:15:03 PM5/13/09
to JFXtras Users
Hi

I have a node that I want to put into "south" of a docking Mig
layout. I want the node to have a fixed height and width vary with
resizing. The control needs to know what its present width is.

In MyControl I watch for sizing :

public class MyControl extends CustomNode, Resizable {
var windowWidth: Number = bind width on replace {
System.out.print("myctl ww ");
System.out.print(width);
System.out.print(" h ");
System.out.println(height);
}
var windowHeight: Number = bind height on replace {
System.out.print("myctl wh ");
System.out.print(height);
}
...
}

When I insert my node I use :

MigLayout {
layout: "fill"
migContent: [
MigNode {
constraints: "grow"
node: MyControl {
height: CONSTANT_HEIGHT
}
}
]
}

When I resize the window I see the expected width, but height is never
set/modified. I print it in windowWidth and it's always 0 (and I
never see my node).

I have never used MigLayout before and I must be missing something
obvious. I would greatly appreciate any pointers.

Thanks
Peter

Dean Iverson

unread,
May 18, 2009, 11:15:04 AM5/18/09
to jfxtra...@googlegroups.com
Peter,

What is MyControl returning for min/pref/max height?

Tip for easier printing: there is no need to qualify with System.out and you can use embedded string expressions.

  println( "myctl ww {width} h {height}" );

Dean

pbl...@hotmail.com

unread,
May 19, 2009, 12:11:45 AM5/19/09
to JFXtras Users
I just looked through the javadoc for CustomNode and Node, and I don't
see any way to "return" those dimensions. I do see that a Node has a
boundsIn{Local|Parent|Scene}. I have not tried to set these. I
assume boundsInLocal is the one I want. I will give it a try, but in
the mean time if that's not what you meant then feel free to comment.

Thanks & Regards
Peter

Dean Iverson

unread,
May 21, 2009, 4:03:57 PM5/21/09
to jfxtra...@googlegroups.com
Peter,

If a node is Resizable (check the javafx.scene.layout package) then it will have a min/pref/max width and height.  MigLayout will use those values to size the node.  If it is not Resizable, then MigLayout will only position the node, not size it.

Dean
Reply all
Reply to author
Forward
0 new messages