I have an application where I have a table and ProgressBar
. I want to expand my progress bar when user resizes the window. For TextBox
in JavaFX I can able to set HBox
priority and achieve it as intended. But for ProgressBar
it is not working.
Can any one tell me where I am doing wrong ?
HBox root = new HBox();
final ProgressBar browser = new ProgressBar();
// final WebEngine webEngine = browser.getEngine();
// browser.setText("JJJ");
HBox.setHgrow(browser, Priority.ALWAYS);
// webEngine.loadContent("<b>asdf</b>");
root.getChildren().add(browser);
scene.setRoot(root);
Bind the widths of progress bar and Vbox:
VBox root = new VBox();
root.setAlignment(Pos.TOP_CENTER);
final ProgressBar browser = new ProgressBar();
browser.prefWidthProperty().bind(root.widthProperty().subtract(20)); // -20 is for
// padding from right and left, since we aligned it to TOP_CENTER.
root.getChildren().add(browser);