2014-10-29 5 views
2

Я пытаюсь изменить размер двух таблиц в анкерной панели, когда этап максимизирован, чтобы иметь ту же пропорцию, что и размеры ступени по умолчанию.Resize TableView, когда этап максимизирован

Теперь у меня есть, что:

http://i.imgur.com/Z6Lywhr.png

Но когда максимизируется есть много пространства между ними:

http://i.imgur.com/NZa5wY0.png

Я искал, и я нашел ответы на аналогичный вопросы, касающиеся обертывания сеткой, но даже так, я не могу этого сделать:

JavaFX tableview resize to fit window

Кому-то известно, что здесь отсутствует?

Код FXML:

<AnchorPane styleClass="backgroundColor" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="solverassistant.FXMLCompareController"> 
    <children> 
     <AnchorPane prefHeight="270" prefWidth="190.0" styleClass="filterPane" AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="40.0"> 
      <children> 
       <Label id="filterLabel" fx:id="filterLabel" alignment="CENTER" prefHeight="17.0" prefWidth="150.0" text="Filter" AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="10.0" /> 
       <TextField id="filterTextField" fx:id="filterTextField" alignment="CENTER" layoutY="20.0" prefWidth="150.0" AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="30.0" /> 
       <Label id="filterByLabel" fx:id="filterByLabel" alignment="CENTER" prefHeight="17.0" prefWidth="150.0" text="Filter by:" AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="70.0" /> 
       <CheckBox id="solverCheckBox" fx:id="solverCheckBox" layoutY="90.0" selected="true" text="Solver" AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="100.0" /> 
       <CheckBox id="benchmarkCheckBox" fx:id="benchmarkCheckBox" layoutY="110.0" selected="true" text="Benchmark" AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="120.0" /> 
       <CheckBox id="typeCheckBox" fx:id="typeCheckBox" layoutY="130.0" selected="true" text="Solver type" AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="140.0" /> 
       <CheckBox id="timeOutCheckBox" fx:id="timeOutCheckBox" layoutY="150.0" selected="true" text="Time out" AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="160.0" /> 
       <CheckBox id="memoryCheckBox" fx:id="memoryCheckBox" layoutY="170.0" selected="true" text="Memory" AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="180.0" /> 
       <CheckBox id="coresCheckBox" fx:id="coresCheckBox" layoutY="190.0" selected="true" text="Number of cores" AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="200.0" /> 
       <CheckBox id="wholeWordCheckBox" fx:id="wholeWordCheckBox" layoutY="190.0" selected="false" text="Whole word" AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="220.0" /> 
      </children> 
     </AnchorPane> 
     <Button id="reloadButton" fx:id="reloadButton" onAction="#resetAndReloadSolvers" prefHeight="25.0" prefWidth="190.0" styleClass="button-defaultButton" text="Reset and reload data" AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="320.0" /> 
     <Button id="compareButton" fx:id="compareButton" disable="true" prefHeight="25.0" prefWidth="150.0" styleClass="button-defaultButton" text="Compare" AnchorPane.bottomAnchor="50.0" AnchorPane.leftAnchor="40.0" /> 
     <TableView id="allSolversTable" fx:id="allSolversTable" minHeight="-Infinity" prefHeight="175.0" prefWidth="922.0" AnchorPane.leftAnchor="245.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="40.0"> 
      <columnResizePolicy> 
       <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" /> 
      </columnResizePolicy> 
      <columns> 
       <TableColumn fx:id="colAllSelect" prefWidth="25.0" /> 
       <TableColumn fx:id="colAllSolver" prefWidth="75.0" text="Solver" /> 
       <TableColumn fx:id="colAllBenchmark" prefWidth="75.0" text="Benchmark" /> 
       <TableColumn fx:id="colAllSolverType" prefWidth="75.0" text="Solver type" /> 
       <TableColumn fx:id="colAllTimeOut" prefWidth="75.0" text="Time out" /> 
       <TableColumn fx:id="colAllMemory" prefWidth="75.0" text="Memory" /> 
       <TableColumn fx:id="colAllNumberOfCores" prefWidth="75.0" text="Number of cores" /> 
      </columns> 
     </TableView> 
     <TableView id="selectedSolversTable" fx:id="selectedSolversTable" minHeight="-Infinity" prefHeight="175.0" prefWidth="922.0" AnchorPane.bottomAnchor="50.0" AnchorPane.leftAnchor="245.0" AnchorPane.rightAnchor="0.0"> 
      <columnResizePolicy> 
       <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" /> 
      </columnResizePolicy> 
      <columns> 
       <TableColumn fx:id="colSelectedSolver" prefWidth="75.0" text="Solver" /> 
       <TableColumn fx:id="colSelectedBenchmark" prefWidth="75.0" text="Benchmark" /> 
       <TableColumn fx:id="colSelectedSolverType" prefWidth="75.0" text="Solver type" /> 
       <TableColumn fx:id="colSelectedTimeOut" prefWidth="75.0" text="Time out" /> 
       <TableColumn fx:id="colSelectedMemory" prefWidth="75.0" text="Memory" /> 
       <TableColumn fx:id="colSelectedNumberOfCores" prefWidth="75.0" text="Number of cores" /> 
      </columns> 
     </TableView> 
    </children> 
</AnchorPane> 

Все проекты: github.com/danielcasanovas/SolverAssistant

ответ

1

Один простой, что вы можете сделать, это просто обернуть обе таблицы в VBox, пусть первая таблица имеет вертикальную Grow приоритет установлен как ALWAYS и установить USE_COMPUTE_SIZE во все поля min/pref/max. Вторая таблица может быть такой, как была (так что только первый будет изменен).

Это пораженную часть файла FXML:

<VBox spacing="40.0" AnchorPane.bottomAnchor="40.0" AnchorPane.leftAnchor="245.0" AnchorPane.rightAnchor="40.0" AnchorPane.topAnchor="40.0"> 
    <children> 
      <TableView id="allSolversTable" fx:id="allSolversTable" VBox.vgrow="ALWAYS"> 
       <columnResizePolicy> 
        <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" /> 
       </columnResizePolicy> 
       <columns> 
        <TableColumn fx:id="colAllSelect" prefWidth="25.0" /> 
        <TableColumn fx:id="colAllSolver" prefWidth="75.0" text="Solver" /> 
        <TableColumn fx:id="colAllBenchmark" prefWidth="75.0" text="Benchmark" /> 
        <TableColumn fx:id="colAllSolverType" prefWidth="75.0" text="Solver type" /> 
        <TableColumn fx:id="colAllTimeOut" prefWidth="75.0" text="Time out" /> 
        <TableColumn fx:id="colAllMemory" prefWidth="75.0" text="Memory" /> 
        <TableColumn fx:id="colAllNumberOfCores" prefWidth="75.0" text="Number of cores" /> 
       </columns> 
      </TableView> 
      <TableView id="selectedSolversTable" fx:id="selectedSolversTable" prefHeight="175.0"> 
       <columnResizePolicy> 
        <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" /> 
       </columnResizePolicy> 
       <columns> 
        <TableColumn fx:id="colSelectedSolver" prefWidth="75.0" text="Solver" /> 
        <TableColumn fx:id="colSelectedBenchmark" prefWidth="75.0" text="Benchmark" /> 
        <TableColumn fx:id="colSelectedSolverType" prefWidth="75.0" text="Solver type" /> 
        <TableColumn fx:id="colSelectedTimeOut" prefWidth="75.0" text="Time out" /> 
        <TableColumn fx:id="colSelectedMemory" prefWidth="75.0" text="Memory" /> 
        <TableColumn fx:id="colSelectedNumberOfCores" prefWidth="75.0" text="Number of cores" /> 
       </columns> 
      </TableView> 
    </children> 
    </VBox> 

Без дальнейших изменений в основной файл FXML, таблица должна изменить размер правильно после любого изменения размера приложения.

+0

Идеальное и легкое решение для небольшой проблемы, спасибо! –

+0

Для проблем с компоновкой, как правило, 'VBox' и' HBox' пригодится. До сих пор ваш проект действительно хорош. –

+0

Я сделаю это, большое вам спасибо. Можно все вырастить? Как ярлыки в HBox? –

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

  • Нет связанных вопросов^_^