What if you used an HBox
rather than a Toolbar
? I know you don't get the look of the toolbar, but it is easy to float things to the right using a regular Pane
with the Hgrow attribute set to ALWAYS as a spacer. Here (total hack), I put a Toolbar
behind the HBox in a StackPane to let the look of it come through, but you could certainly do that better with css. Also, you will, or course, need id's on your buttons in order to work with them. I also didn't bring forward your embedded controller definition, so don't forget to include that.
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ToolBar?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.StackPane?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1">
<top>
<StackPane BorderPane.alignment="CENTER">
<BorderPane.margin>
<Insets />
</BorderPane.margin>
<children>
<ToolBar prefHeight="40.0" prefWidth="200.0" />
<HBox prefHeight="40.0" prefWidth="200.0">
<children>
<Pane maxWidth="1.7976931348623157E308" HBox.hgrow="ALWAYS" />
<Button mnemonicParsing="false" text="_" />
<Button mnemonicParsing="false" text="O" />
<Button mnemonicParsing="false" text="X" />
</children>
<padding>
<Insets bottom="6.0" left="6.0" right="6.0" top="6.0" />
</padding>
</HBox>
</children>
</StackPane>
</top>
</BorderPane>