I am now learning Javafx and Scalafx, I have got a class called Room, which holds name:String, width:Long, length:Long and a position:Insets and in this class there is a method render which returns a scalafx.scene.Node
def render()={
val stack=new StackPane
val vbox=new VBox
vbox.getChildren.addAll(new Text(name))
stack.getChildren.addAll(new Rectangle(width,length),vbox)
Node.sfxNode2jfx(stack)
}
and I have a class called house which holds a list of Room
val room_list:Seq[Room]
and also I have a render method:
override def render=
{
val ap=new AnchorPane
for(i <- 0 until room_list.length)
{
AnchorPane.setLeftAnchor(room_list(i).render,room_list(i).position.left)
AnchorPane.setRightAnchor(room_list(i).render,room_list(i).position.right)
AnchorPane.setTopAnchor(room_list(i).render,room_list(i).position.top)
AnchorPane.setBottomAnchor(room_list(i).render,room_list(i).position.bottom)
}
}
at last I want to draw this AnchorPane in the main class, but actually what I got is that, all those rooms are setteled on the top left corner, which means the for loop for AnchorPane is compeletly useless, why?