resize - JavaFX Resizing TextField with Window -


in javafx, how create textfield inside hbox (borderpane layout) resize in width/length user resizes window?

you can set hgrow textfield priority.always.

this enable textfield shrink/grow whenever hbox changes width.

mcve :

import javafx.application.application; import javafx.geometry.insets; import javafx.geometry.pos; import javafx.scene.scene; import javafx.scene.control.textfield; import javafx.scene.layout.borderpane; import javafx.scene.layout.hbox; import javafx.scene.layout.priority; import javafx.stage.stage;  public class main extends application {      @override     public void start(stage primarystage) throws exception {         textfield textfield = new textfield();          hbox container  = new hbox(textfield);         container.setalignment(pos.center);         container.setpadding(new insets(10));          // set hgrow textfield         hbox.sethgrow(textfield, priority.always);          borderpane pane = new borderpane();         pane.setcenter(container);         scene scene = new scene(pane, 150, 150);         primarystage.setscene(scene);         primarystage.show();     }      public static void main(string[] args) {         launch(args);     } } 

output :

enter image description here


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -