SimonC
SimonC

Reputation: 1617

JavaFX equivalent to WPF Margin?

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!

Upvotes: 1

Views: 316

Answers (1)

jewelsea
jewelsea

Reputation: 159466

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.

Upvotes: 4

Related Questions