2016-08-14 13 views
1

これは、親ペインに合わせて子ペインのサイズを変更することに関してたくさんの質問があるので、重複しているように聞こえるかもしれませんが、SplitPaneをAnchorPane親に合わせてサイズを変更する

私をSplitPaneはAnchorPaneの内側に位置しており、これが私の元のコードです:私は幅を大きくするためにウィンドウをドラッグすると

enter image description here

か:

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" 
    minWidth="-Infinity" prefHeight="792.0" prefWidth="1055.0" 
    xmlns="http://javafx.com/javafx/null" xmlns:fx="http://javafx.com/fxml/1" 
    fx:controller="com.judeochalifu.stock_manager.controller.NewSupplierController"> 
    <children> 
     <SplitPane fx:id="splitPlane" dividerPositions="0.5" layoutX="371.0" layoutY="229.0" prefHeight="792.0" prefWidth="1055.0"orientation="VERTICAL" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> 
    <items> 
     <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0" /> 
     <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0" /> 
    </items> 
    </SplitPane> 
</children> 
</AnchorPane> 

これはリサイズせずに出力されます高さ、これは私が得るものです:

enter image description here

結果は、ウィンドウの展開、つまりアンカーパネルの幅と高さに応じてサイズを変更するためにSplitPaneが使用されるためです。内部

AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" 

:答えは属性のみを使用することをお勧めし

JavaFX: FXML: How to make the child to extend its size to fit the parent pane?

JavaFX Panel inside Panel autoresizing

:私はOPは類似した何かをしようとしているこれら二つの質問を見つけたの周り探し

子ペイン。私は運が無ければこれを試しました:これは私のコードが今のようになります:

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" 
     minWidth="-Infinity" prefHeight="792.0" prefWidth="1055.0" 
     xmlns="http://javafx.com/javafx/null" xmlns:fx="http://javafx.com/fxml/1" 
    fx:controller="com.judeochalifu.stock_manager.controller.NewSupplierController"> 
    <children> 
     <SplitPane fx:id="splitPlane" dividerPositions="0.5" "orientation="VERTICAL" 
      AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" 
      AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> 
      <items> 
      <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" 
       prefWidth="160.0" /> 
      <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" 
       prefWidth="160.0" /> 
      </items> 
     </SplitPane> 
    </children> 
    </AnchorPane> 

私は何が欠けていますか?

+0

内側アンカー枠のprefHeight、prefWidthを削除してみます。 – yamenk

答えて

0

エラーがあるため、コードをコンパイルできませんでした。最初の例ではprefWidthorientationの間に空白があり、2番目の例ではorientationの直前に不要な引用符があります。それらを固定した後、すべてが期待通りに機能します。

ここでは固定コードです:あなたは、あなたをSplitPaneのprefWidthprefHeightlayoutXlayoutYを指定することができますが、アンカーが0に設定されているので、それはAnchorPaneの唯一の子だ

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" 
      minWidth="-Infinity" prefHeight="792.0" prefWidth="1055.0" 
      xmlns="http://javafx.com/javafx/null" xmlns:fx="http://javafx.com/fxml/1" 
      fx:controller="com.judeochalifu.stock_manager.controller.NewSupplierController"> 
    <children> 
     <SplitPane fx:id="splitPlane" dividerPositions="0.5" orientation="VERTICAL" 
        AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" 
        AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> 
      <items> 
       <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0"/> 
       <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0"/> 
      </items> 
     </SplitPane> 
    </children> 
</AnchorPane> 

注それは常に余裕があるようにすべての空き領域を占有します。

関連する問題