2016-06-07 4 views
2

Я пытаюсь запустить этот FXML код в JavaFX:Как установить границу поля BorderPane в fxml?

<BorderPane fx:controller="com.bryantmorrill.chat.main.Controller" 
     xmlns:fx="http://javafx.com/fxml" > 

<center> 
    <ScrollPane BorderPane.margin="25, 25, 25, 25"> 
     <content> 
      <TextArea fx:id="chatArea" minWidth="200" maxWidth="450" 
         prefWidth="450" minHeight="200" prefHeight="400" 
         maxHeight="400"/> 
     </content> 
    </ScrollPane> 
</center> 

<bottom> 
    <FlowPane BorderPane.margin="25, 25, 25, 25"> 
     <TextField fx:id="inputArea" minWidth="200" maxWidth="450" prefWidth="450"/> 
     <Button text="Send" onAction="#sendMessage" minWidth="200" maxWidth="450" prefWidth="450"/> 
    </FlowPane> 

</bottom> 

Однако терпит неудачу, когда я пытаюсь установить поле таким образом:

<ScrollPane BorderPane.margin="25, 25, 25, 25"> 

Я также пробовал эти методы:

<ScrollPane BorderPane.margin="25 25 25 25"> 
<ScrollPane BorderPane.margin="25"> 

Это исключение, которое я получаю со всеми их:

java.lang.IllegalArgumentException: Unable to coerce 25, 25, 25, 25 to class javafx.geometry.Insets. 

Это мой первый опыт использования JavaFX, и я не нашел хороших примеров этого. Спасибо за любую помощь!

ответ

5

Вам нужно добавить поля, как субэлементе дочернего узла BorderPane:

<center> 
    <ScrollPane> 
     <BorderPane.margin> 
      <Insets bottom="25.0" left="25.0" right="25.0" top="25.0" /> 
     </BorderPane.margin> 
     <content> 
      <TextArea fx:id="chatArea" minWidth="200" maxWidth="450" 
         prefWidth="450" minHeight="200" prefHeight="400" 
         maxHeight="400"/> 
     </content> 
    </ScrollPane> 
</center> 
<bottom> 
    <FlowPane> 
     <BorderPane.margin> 
      <Insets bottom="25.0" left="25.0" right="25.0" top="25.0" /> 
     </BorderPane.margin> 
     <TextField fx:id="inputArea" minWidth="200" maxWidth="450" prefWidth="450"/> 
     <Button text="Send" onAction="#sendMessage" minWidth="200" maxWidth="450" prefWidth="450"/> 
    </FlowPane> 
</bottom> 
+0

Спасибо! Это то, что мне нужно. – zephos2014

Смежные вопросы