1
votes

I'm new to JavaFX, but I'm used to developing/designing applications in WPF for C#, and I want my window to be maximizable due to some hefty controls and lists. Is there an equivalent to WPF's margin in JavaFX so the controls will stay put when the window's size changes?

Thanks in advance!

1
What exactly is WPF's margin ? - ItachiUchiha
msdn.microsoft.com/en-us/library/… Let's say you have a ComboBox on the left of your screen. Next to that, you want to have another ComboBox. You set the horizontal alignment to the left and you can then set a margin (in pixels) so that the control will always be in that position, no matter what size the window is. - SimonC

1 Answers

4
votes

No, there is no exact equivalent in JavaFX 8 to WPF margin support for all nodes.

A feature request to add node margin support is currently scheduled to be implemented for Java 9.

For the use case you detail (having controls stay put when the window's size changes), a couple of potential solutions are:

  • Use an absolute positioning layout container such as an AnchorPane.
  • Use a GridPane which has margin support.
  • Tweak the padding values on your nodes.
  • Set spacing for hbox/vbox style controls.
  • Using struts as outlined in James Weaver's (somewhat dated and slightly obsolete) document on JavaFX layout.