how to make child auto-resize (child is Pane, parent is VBox) in javafx -


i have 2 questions

1.in javafx application, want put child(crosshairarea) @ left-top corner of parent, 1/2 width , height well. think can via override parent function "layoutchildren" (vbox), there other way that? e.g. property binding?

2.initially vbox occupy full scene area, how make(relocate) half-bottom of scene?

public class crossh extends application {      public static void main(string[] args) {         launch(args);     }      @override     public void start(stage stage) {                 vbox root = new vbox(5);         // root.setpadding(new insets(20,20,20,20));         root.setstyle("-fx-border-color:red");          pane crosshairarea = new pane();         crosshairarea.maxwidthproperty().bind(root.widthproperty());         crosshairarea.setstyle("-fx-border-color:black");                 root.getchildren().add(crosshairarea);         scene scene = new scene(root);         stage.setscene(scene);         stage.settitle("location crosshair");         stage.setwidth(900);         stage.setheight(700);                 stage.show();     } } 

for first question have tried height property of vbox. example

root.heightproperty().addlistener(new changelistener<number>() {          @override         public void changed(observablevalue<? extends number> arg0,                 number arg1, number arg2) {             crosshairarea.setprefheight(arg2.doublevalue()/2);      } }); 

for second question, have put on top of vbox occupy size on top or can set alignment of vbox pos.bottom


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -