I am looking for a way to say set a maxWidth size to 80% in FXML.
Much like in web development.
<VBox fx:id="testVB" prefWidth="600">
But this does not:
<VBox fx:id="testVB" prefWidth="80%">
I know that in Straight JavaFX2 non-fxml you can create insets? What is the best way to do this outside of code in FMXL?
Thanks!
Riley
I’m not sure you can. You need to use the
GridPanelayout component. In this component, you can specify rows and columns constraints, and in these constraints you can specify a width as a percentage. For example:This code defines a
GridPanewith a first column with a width of 80%. TheTitledPaneis set in the first cell of the first column of thisGridPane, and can (because you need to be sure that the width constraints of theTitledPanematch your needs) occupy 80% of the width of theGridPane.Please note that I removed all information not relevant to your question. By the way, Oracle’s Scene Builder tool is very useful to define complex FXML layout.