2017-05-20 1 views
1

경계선 내에 표를 배치하려고합니다. 그렇게하면 창을 축소하면 표가 잘리고 스크롤바가 표시되지 않습니다. JFX BorderPane에 스크롤 막대가 없습니다.

레이아웃입니다 :

<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="1000.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="javafxapplication1.SimpleUIController"> 
<center> 
<AnchorPane> 
     <TableView fx:id="table" prefHeight="500.0" prefWidth="1000.0" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="50.0" AnchorPane.topAnchor="10.0" BorderPane.alignment="CENTER"> 
     <columns> 
      <TableColumn fx:id="colName" prefWidth="500.0" text="Name" /> 
      <TableColumn fx:id="colPrice" prefWidth="400.0" text="Price" /> 
     </columns> 
     </TableView> 
</AnchorPane> 
</center> 
</BorderPane> 

그리고 이것은이 만든 창 모습입니다 테이블보다 작 : enter image description here

나는 국경 창과 같이 제거하는 경우 :

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="1000.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="javafxapplication1.SimpleUIController"> 
     <TableView fx:id="table" prefHeight="500.0" prefWidth="1000.0" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="50.0" AnchorPane.topAnchor="10.0"> 
     <columns> 
      <TableColumn fx:id="colName" prefWidth="500.0" text="Name" /> 
      <TableColumn fx:id="colPrice" prefWidth="400.0" text="Price" /> 
     </columns> 
     </TableView> 
</AnchorPane> 

원하는대로 스크롤 막대가 표시됩니다. enter image description here

경계선을 사용할 때 어떻게 스크롤바를 얻을 수 있습니까? 다음과 같이 부모 노드로의 ScrollPane을 설정

답변

0

시도 : 나는 창을 확대하는 경우, 그러나, 나는 필요에 가까운 모습

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

<?import javafx.scene.control.ScrollPane?> 
<?import javafx.scene.control.TableColumn?> 
<?import javafx.scene.control.TableView?> 
<?import javafx.scene.layout.BorderPane?> 
<?import javafx.scene.layout.HBox?> 
<?import javafx.scene.layout.VBox?> 


<HBox 
    maxHeight="1.7976931348623157E308" 
    maxWidth="1.7976931348623157E308" 
    xmlns="http://javafx.com/javafx/8.0.111" 
    xmlns:fx="http://javafx.com/fxml/1"> 
    <children> 
     <VBox 
      maxHeight="1.7976931348623157E308" 
      maxWidth="1.7976931348623157E308" 
      HBox.hgrow="ALWAYS"> 
      <children> 
       <ScrollPane 
        fitToHeight="true" 
        fitToWidth="true" 
        maxHeight="1.7976931348623157E308" 
        maxWidth="1.7976931348623157E308" 
        VBox.vgrow="ALWAYS"> 
        <content> 
         <BorderPane 
          maxHeight="1.7976931348623157E308" 
          maxWidth="1.7976931348623157E308" 
          minHeight="-Infinity" 
          minWidth="-Infinity"> 
          <center> 
           <TableView 
            maxHeight="1.7976931348623157E308" 
            maxWidth="1.7976931348623157E308"> 
            <columns> 
             <TableColumn 
              maxWidth="1.7976931348623157E308" 
              prefWidth="400.0" 
              text="C1" /> 
             <TableColumn 
              maxWidth="1.7976931348623157E308" 
              prefWidth="500.0" 
              text="C2" /> 
            </columns> 
            <columnResizePolicy> 
             <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" /> 
            </columnResizePolicy> 
           </TableView> 
          </center> 
         </BorderPane> 
        </content> 
       </ScrollPane> 
      </children> 
     </VBox> 
    </children> 
</HBox> 

Screenshot

+1

가 표는 사용 가능한 공간을 사용하지 않습니다. 방금 테이블 주위에 빈 공간이 많습니다. 나는 그것을 피할 수 있습니까? – zorro2b

+0

@ zorro2b 업데이트 된 코드를 사용해보십시오. 포장의 많은 층을 가지고있는 작은 메시지이지만, 잘하면 일할 것입니다. – anishthecoder

관련 문제