2016-07-06 9 views
1

FXML Layout für die ChatbotView.fxmlJavaFX: Der Versuch, gleichmäßig Raum Symbolleiste Elemente mit FXML

<?xml version="1.0" encoding="UTF-8"?> 

<?import javafx.scene.control.Button?> 
<?import javafx.scene.control.TextField?> 
<?import javafx.scene.control.ToolBar?> 
<?import javafx.scene.layout.BorderPane?> 
<?import javafx.scene.text.Font?> 

<BorderPane id="background" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="706.0" stylesheets="@ChatbotStyle.css" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1"> 
    <top> 
     <ToolBar prefHeight="40.0" prefWidth="200.0" styleClass="spacer" BorderPane.alignment="CENTER"> 
     <items> 
      <Button mnemonicParsing="false" text="Calendar"> 
       <font> 
        <Font size="14.0" /> 
       </font></Button> 
      <Button mnemonicParsing="false" text="Topic List"> 
       <font> 
        <Font size="14.0" /> 
       </font></Button> 
      <TextField> 
       <font> 
        <Font size="14.0" /> 
       </font></TextField> 
      <Button mnemonicParsing="false" text="Chatbot's Button"> 
       <font> 
        <Font size="14.0" /> 
       </font></Button> 
      <Button mnemonicParsing="false" text="Quit"> 
       <font> 
        <Font size="14.0" /> 
       </font></Button> 
     </items> 
     </ToolBar> 
    </top> 
    <bottom> 
     <ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER"> 
     <items> 
      <Button mnemonicParsing="false" text="Map"> 
       <font> 
        <Font size="14.0" /> 
       </font></Button> 
      <Button mnemonicParsing="false" text="Load from File"> 
       <font> 
        <Font size="14.0" /> 
       </font></Button> 
      <Button mnemonicParsing="false" text="Save to File"> 
       <font> 
        <Font size="14.0" /> 
       </font></Button> 
      <Button mnemonicParsing="false" text="Send Tweet"> 
       <font> 
        <Font size="14.0" /> 
       </font></Button> 
      <Button mnemonicParsing="false" text="Search Twitter"> 
       <font> 
        <Font size="14.0" /> 
       </font></Button> 
     </items> 
     </ToolBar> 
    </bottom> 
</BorderPane> 

Ich bin nur, um herauszufinden, wie gleichmäßig Raum, um alle Symbolleiste Elemente so es am Ende so etwas wie folgt aussehen:

enter image description here

Vielen Dank im Voraus.

Antwort

2

außer Kraft setzen Sie einfach den CSS-Stil für die Symbolleiste:

.tool-bar { /* top */ 
    -fx-alignment: CENTER; 
} 

Oder es nur direkt in fxml gesetzt:

<ToolBar style="-fx-alignment: CENTER" ...> 
+0

Dank! Die Änderung des CSS-Codes hat absolut den Zweck erfüllt. –