Search code examples
javafxjavafx-2separator

Apply JavaFX Separator to BorderPane


Am in an attempt to include Separator into BorderPane in my Java application, which is developing using JavaFX. I know how to include the Separator in a region of the BorderPane, that is in Top, Bottom, Left, Right or Center.

I want to implement a Separator in between 2 regions of the BorderPane, say Center and Right. The Separator should appear as a border between the Center and Right regions. I use either VBox or HBox in the regions of the BorderPane.

How can use Separator in the way I described ?


Solution

  • You can add a separator as the last element of your HBox. Lets consider,two scenarios :

    1. you are using Center and Right part of the BorderPane and you have a Hbox inside your Center. So to put a separator between Center and Right, you can just place a separator as the Last element of the HBox.

    2. If you have a VBox in the Center, you can wrap the VBox in a HBox and put the Separator as the second child of the HBox.