JavaFX Loader not loading - javafx

This is my Main Class:
public class Main extends Application {
#Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("mainmenu.fxml"));
primaryStage.setTitle("Horse Manager");
primaryStage.setScene(new Scene(root,400,600));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
And I am getting this error:
Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:745)
Caused by: javafx.fxml.LoadException:
/C:/Users/nikit/IdeaProjects/SEPM/out/production/SEPM/sepm/ss17/e1526589/GUI/XMLs/mainmenu.fxml:42
and this is the fxml made with SceneBuilder:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Accordion?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.TitledPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Text?>
<BorderPane fx:id="root" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="500" minWidth="500" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sepm.ss17.e1526589.GUI.XMLs.Controllers.MainMenuController">
<top>
<MenuBar BorderPane.alignment="CENTER">
<menus>
<Menu mnemonicParsing="false" text="File">
<items>
<MenuItem mnemonicParsing="false" text="Close" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Edit">
<items>
<MenuItem mnemonicParsing="false" text="Delete" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Help">
<items>
<MenuItem mnemonicParsing="false" text="About" />
</items>
</Menu>
</menus>
</MenuBar>
</top>
<left>
<Accordion BorderPane.alignment="CENTER">
<panes>
<TitledPane prefHeight="200.0" prefWidth="200.0" text="Boxes">
<content>
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Button fx:id="boxSearch" mnemonicParsing="false" prefWidth="250.0" text="Search" />
<Button fx:id="boxCD" mnemonicParsing="false" prefWidth="250.0" text="Create/Delete Box" />
<Button fx:id="boxUpdate" mnemonicParsing="false" prefWidth="250.0" text="Update Box" />
</children>
</VBox>
</content>
</TitledPane>
<TitledPane animated="false" text="Customers">
<content>
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Button fx:id="customerSearch" mnemonicParsing="false" prefWidth="250.0" text="Search" />
<Button fx:id="customerCD" mnemonicParsing="false" prefWidth="250.0" text="Customer New/Old" />
<Button fx:id="customerUpdate" mnemonicParsing="false" prefWidth="250.0" text="Update Cutomer" />
</children>
</VBox>
</content>
</TitledPane>
<TitledPane animated="false" text="Reservations">
<content>
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Button fx:id="reservationsSearch" mnemonicParsing="false" prefWidth="250.0" text="Search" />
<Button fx:id="reservationsCD" mnemonicParsing="false" prefWidth="250.0" text="Create/Delete Reservations" />
<Button fx:id="reservationsUpdate" mnemonicParsing="false" prefWidth="250.0" text="Update Reservations" />
</children>
</VBox>
</content>
</TitledPane>
<TitledPane prefHeight="200.0" prefWidth="200.0" text="Bills">
<content>
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Button fx:id="billsSearch" mnemonicParsing="false" prefWidth="250.0" text="Search" />
<Button fx:id="billsCD" mnemonicParsing="false" prefWidth="250.0" text="Create/Delete Bills" />
<Button fx:id="billsUpdate" mnemonicParsing="false" prefWidth="250.0" text="Update Bills" />
</children>
</VBox>
</content>
</TitledPane>
<TitledPane prefHeight="200.0" prefWidth="200.0" text="Statistics">
<content>
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Button mnemonicParsing="false" prefWidth="250.0" text="Search" />
<Button mnemonicParsing="false" prefWidth="250.0" text="Create/Delete Box" />
<Button mnemonicParsing="false" prefWidth="250.0" text="Update Box" />
</children>
</VBox>
</content>
</TitledPane>
</panes>
</Accordion>
</left>
<center>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Welcome to Horse Manager" BorderPane.alignment="CENTER" />
</center>
</BorderPane>
my path works and I dont know what else could be wrong the error happens because of the .load function from what I can tell. Please Help

Related

Changes in the fxml file are not visible

Basically when i update my .fxml file, i can't see the new stuff...it's like showing the old version of the .fxml...with the old stuff... and yes i save the file...
This is my Main.java
package Library.Assistant.Ui.Main;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class MainLoader extends Application {
public static void main(String arg[]) {
launch(arg);
}
#Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("Main.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
}
This is my Main.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXTextField?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<VBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="548.0" prefWidth="617.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Library.Assistant.Ui.Main.MainController">
<children>
<MenuBar maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308">
<menus>
<Menu mnemonicParsing="false" text="File">
<items>
<MenuItem mnemonicParsing="false" text="Close" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Edit">
<items>
<MenuItem mnemonicParsing="false" text="Delete" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Help">
<items>
<MenuItem mnemonicParsing="false" text="About" />
</items>
</Menu>
</menus>
</MenuBar>
<GridPane fx:id="grid" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" VBox.vgrow="ALWAYS">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<TabPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" tabClosingPolicy="UNAVAILABLE" GridPane.rowSpan="2147483647">
<tabs>
<Tab text="Book Issue">
<content>
<VBox alignment="CENTER" prefHeight="200.0" prefWidth="100.0">
<children>
<HBox alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" VBox.vgrow="ALWAYS">
<children>
<TextField fx:id="enterBookID" promptText="Enter Book ID" />
<VBox alignment="CENTER" prefHeight="200.0" prefWidth="100.0" HBox.hgrow="ALWAYS">
<children>
<Label text="Book Name" />
<Label text="Author" />
</children>
</VBox>
</children>
</HBox>
<HBox alignment="CENTER" layoutX="10.0" layoutY="10.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" VBox.vgrow="ALWAYS">
<children>
<TextField promptText="Enter Member ID" />
<VBox alignment="CENTER" prefHeight="200.0" prefWidth="100.0" HBox.hgrow="ALWAYS">
<children>
<Label text="Member Name" />
<Label text="Contact" />
</children>
</VBox>
</children>
</HBox>
<HBox alignment="CENTER" layoutX="10.0" layoutY="404.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" VBox.vgrow="ALWAYS">
<children>
<JFXButton maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" text="Issue" HBox.hgrow="ALWAYS" />
</children>
</HBox>
</children>
</VBox>
</content>
</Tab>
<Tab text="Renew / Submission">
<content>
<VBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308">
<children>
<BorderPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" VBox.vgrow="ALWAYS">
<top>
<JFXTextField alignment="CENTER" promptText="Enter Book ID" BorderPane.alignment="CENTER">
<BorderPane.margin>
<Insets bottom="20.0" left="10.0" right="10.0" top="10.0" />
</BorderPane.margin>
</JFXTextField>
</top>
<center>
<ListView maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" BorderPane.alignment="CENTER" />
</center>
<bottom>
<HBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" BorderPane.alignment="CENTER">
<children>
<JFXButton maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" text="Renew" HBox.hgrow="ALWAYS" />
<JFXButton maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" text="Submission" HBox.hgrow="ALWAYS" />
</children>
<BorderPane.margin>
<Insets />
</BorderPane.margin>
</HBox>
</bottom>
</BorderPane>
</children>
</VBox>
</content>
</Tab>
</tabs>
</TabPane>
<Button contentDisplay="TOP" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" text="Add Member" GridPane.columnIndex="1">
<graphic>
<ImageView fitHeight="50.0" fitWidth="50.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="#add_mem.png" />
</image>
</ImageView>
</graphic>
</Button>
<Button contentDisplay="TOP" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" text="Add Book" GridPane.columnIndex="1" GridPane.rowIndex="1">
<graphic>
<ImageView fitHeight="50.0" fitWidth="50.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="#add_book.png" />
</image>
</ImageView>
</graphic>
</Button>
<Button contentDisplay="TOP" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" text="View Members" GridPane.columnIndex="1" GridPane.rowIndex="2">
<graphic>
<ImageView fitHeight="50.0" fitWidth="50.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="#list_mem.png" />
</image>
</ImageView>
</graphic>
</Button>
<Button contentDisplay="TOP" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" text="View Books" GridPane.columnIndex="1" GridPane.rowIndex="3">
<graphic>
<ImageView fitHeight="50.0" fitWidth="50.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="#list_book.png" />
</image>
</ImageView>
</graphic>
</Button>
<Button contentDisplay="TOP" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" text="Settings" GridPane.columnIndex="1" GridPane.rowIndex="4">
<graphic>
<ImageView fitHeight="50.0" fitWidth="50.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="#settings.png" />
</image>
</ImageView>
</graphic>
</Button>
</children>
</GridPane>
</children>
</VBox>
I just can't understand why it's showing the old version of the file...yesterday everything was working fine.I was adding new stuff and it was showing them properly, but today it keeps showing the version from yesterday...no matter how many stuff i change..

Label does not get displayed in javafx

I have a borderpane in my application. In the bottom part i wanted to set a Label to display the current status of the program for example: "ready", "reading data" and so on.
When I start the application the bottom section does not get displayed. Only after I changed the height of the window manually with my mouse it suddenly pops up. Does anyone know why this happens? I suppose it has something to do with my listener.
main
package Sample;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class main extends Application {
public static void main(String[] args) {
launch(args);
}
#Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("View/MainWindow.fxml"));
primaryStage.setTitle("Tool-Name");
primaryStage.setScene(new Scene(root));
primaryStage.show();
}
}
fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Accordion?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.SeparatorMenuItem?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.TitledPane?>
<?import javafx.scene.control.cell.PropertyValueFactory?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<BorderPane fx:id="root" prefHeight="453.0" prefWidth="604.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controller.MainWindow_Controller">
<center>
<TabPane fx:id="tpTabs" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="402.0" prefWidth="604.0" tabClosingPolicy="UNAVAILABLE">
<tabs>
<Tab fx:id="tDatabase" text="XXXXXXX">
<content>
<AnchorPane fx:id="apDatabase" minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<Button fx:id="bSetDBPath" layoutX="14.0" layoutY="14.0" mnemonicParsing="false" text="XXXXXXX..." />
<Button fx:id="bSetHeadFilePath" layoutX="14.0" layoutY="66.0" mnemonicParsing="false" text="XXXXXXX..." />
<TextField fx:id="tfDBPath" layoutX="138.0" layoutY="14.0" prefHeight="25.0" prefWidth="255.0" promptText="XXXXXXX" />
<TextField fx:id="tfHeadFilePath" layoutX="138.0" layoutY="66.0" prefHeight="25.0" prefWidth="255.0" promptText="XXXXXXX" />
</children>
</AnchorPane>
</content>
</Tab>
<Tab text="XXXXXXX">
<content>
<Accordion>
<panes>
<TitledPane text="XXXXXXX">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<Button fx:id="bGetNewMembers" layoutX="14.0" layoutY="14.0" mnemonicParsing="false" text="XXXXXXX" />
<Button fx:id="bGetStatusChange" layoutX="14.0" layoutY="58.0" mnemonicParsing="false" text="XXXXXXX" />
<Button fx:id="bRegulation" layoutX="14.0" layoutY="101.0" mnemonicParsing="false" text="XXXXXXX" />
</children>
</AnchorPane>
</content>
</TitledPane>
<TitledPane text="XXXXXXX">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<Button fx:id="bAdministrationData" layoutX="14.0" layoutY="57.0" mnemonicParsing="false" text="XXXXXXX" />
<Button fx:id="bCompareStatus" layoutX="14.0" layoutY="14.0" mnemonicParsing="false" text="XXXXXXX" />
</children>
</AnchorPane>
</content>
</TitledPane>
<TitledPane text="XXXXXXX">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<Button fx:id="bOrganisation" layoutX="14.0" layoutY="103.0" mnemonicParsing="false" text="XXXXXXX" />
<Button fx:id="bDeferredCompensation" layoutX="14.0" layoutY="14.0" mnemonicParsing="false" text="XXXXXXX" />
<Button fx:id="bCompanyMatching" layoutX="14.0" layoutY="60.0" mnemonicParsing="false" text="XXXXXXX" />
</children>
</AnchorPane>
</content>
</TitledPane>
</panes>
</Accordion>
</content>
</Tab>
<Tab fx:id="tTestCases" text="XXXXXXX">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<TableView fx:id="tvTestCases" prefHeight="310.0" prefWidth="600.0">
<columns>
<TableColumn fx:id="tcTestCaseId" prefWidth="132.0" text="XXXXXXX">
<cellValueFactory><PropertyValueFactory property="testCaseId" />
</cellValueFactory>
</TableColumn>
<TableColumn fx:id="tcPaymentId" prefWidth="150.0" text="XXXXXXX">
<cellValueFactory><PropertyValueFactory property="paymentId" />
</cellValueFactory>
</TableColumn>
</columns>
</TableView>
</children>
</AnchorPane>
</content>
</Tab>
<Tab fx:id="tReports" text="XXXXXXX">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<TableView fx:id="tvReports" prefHeight="310.0" prefWidth="604.0">
<columns>
<TableColumn fx:id="tcReportId" editable="false" prefWidth="75.0" text="XXXXXXX" />
<TableColumn fx:id="tcReportType" editable="false" prefWidth="75.0" text="XXXXXXX" />
<TableColumn fx:id="tcCreationDate" editable="false" prefWidth="75.0" text="XXXXXXX" />
</columns>
</TableView>
</children>
</AnchorPane>
</content>
</Tab>
</tabs>
</TabPane>
</center>
<top>
<MenuBar fx:id="mbMenuBar" prefHeight="30.0" prefWidth="604.0" BorderPane.alignment="CENTER">
<menus>
<Menu mnemonicParsing="false" text="XXXXXXX">
<items>
<MenuItem mnemonicParsing="false" text="XXXXXXX" />
<MenuItem mnemonicParsing="false" text="XXXXXXX" />
<SeparatorMenuItem mnemonicParsing="false" />
<MenuItem mnemonicParsing="false" text="XXXXXXX" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="XXXXXXX">
<items>
<Menu mnemonicParsing="false" text="XXXXXXX">
<items>
<MenuItem fx:id="miNewVoucher" mnemonicParsing="false" text="XXXXXXX" />
<MenuItem fx:id="miNewAssociation" mnemonicParsing="false" text="XXXXXXX" />
<MenuItem fx:id="miNewPensioner" mnemonicParsing="false" text="XXXXXXX" />
<MenuItem fx:id="miNewRegulation" mnemonicParsing="false" text="XXXXXXX" />
<MenuItem fx:id="miNewAdministrationCosts" mnemonicParsing="false" text="XXXXXXX" />
<MenuItem fx:id="miNewPayment" mnemonicParsing="false" text="XXXXXXX" />
</items>
</Menu>
<SeparatorMenuItem mnemonicParsing="false" />
<MenuItem fx:id="miOpenDB" mnemonicParsing="false" text="XXXXXXX" />
<MenuItem fx:id="miImportDatasets" mnemonicParsing="false" text="XXXXXXX" />
<SeparatorMenuItem mnemonicParsing="false" />
<MenuItem fx:id="miSetDBPath" mnemonicParsing="false" text="XXXXXXX" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="XXXXXXX">
<items>
<MenuItem fx:id="miOpenManual" mnemonicParsing="false" text="XXXXXXX" />
<MenuItem mnemonicParsing="false" text="XXXXXXX" />
<SeparatorMenuItem mnemonicParsing="false" />
<MenuItem fx:id="miSetManualPath" mnemonicParsing="false" text="XXXXXXX" />
</items>
</Menu>
</menus>
</MenuBar>
</top>
<bottom>
<Label fx:id="lInfo" prefHeight="21.0" prefWidth="604.0" text="Bereit" BorderPane.alignment="CENTER" />
</bottom>
</BorderPane>
Controller
package Controller;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
public class MainWindow_Controller {
#FXML
private BorderPane root;
#FXML
private TableView tvTestCases;
#FXML
private TableView<?> tvReports;
#FXML
MenuBar mbMenuBar;
#FXML
private TabPane tpTabs;
#FXML
private Label lInfo;
/**
* Initialize method to read filepaths and set listeners.
*/
public void initialize() {
tpTabs.setBackground(new Background(new BackgroundFill(Color.BISQUE, null, null)));
loadListener();
lInfo.setText("Bereit");
}
public void loadListener() {
root.widthProperty().addListener(new ChangeListener<Number>() {
#Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
tpTabs.setPrefWidth(root.getWidth());
tvTestCases.setPrefWidth(root.getWidth());
tvReports.setPrefWidth(root.getWidth());
}
});
root.heightProperty().addListener(new ChangeListener<Number>() {
#Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
tpTabs.setPrefHeight(root.getHeight() - mbMenuBar.getHeight()-lInfo.getHeight());
tvTestCases.setPrefHeight(root.getHeight() - mbMenuBar.getHeight()-lInfo.getHeight());
tvReports.setPrefHeight(root.getHeight()-mbMenuBar.getHeight()-lInfo.getHeight());
}
});
}
}
Thank you for any help
You shouldn't adjust the preferred sizes of the nodes during layout. What happens here is that the scene size is determined by calculating the preferred/min/max size before the root size is set. When the root size is set the listeners added in loadListener change the preferred sizes which no longer leaves enough room for all of the nodes. Since the Scene enforces it's size to be smaller than the actual min size of it's root now, the layouts accomodate to this in a some way, in this case by moving the Label out of view.
Do not add those listeners and leave the resizing to the BorderPane. For this to work you need to set the max sizes to sizes other than Region.USE_PREF_SIZE (= -1d/0d = Double.NEGATIVE_INFINITY).
The following opening tag for <TabPane> simply uses the default value (Region.USE_COMPUTED_SIZE). This way the TabPane can grow arbitrary large:
<TabPane fx:id="tpTabs" minHeight="-Infinity" minWidth="-Infinity" prefHeight="402.0" prefWidth="604.0" tabClosingPolicy="UNAVAILABLE">

BorderPanes - JavaFX Scene Builder - Scrollbar down button not visibel

I have a small problem with the position / visibility of the lower scrollbar button of the BorderPanes (EBMTableView) - JavaFX Scene Builder
I want that if I minimize the window, the bottom scrollbar button is always visible.
Thank you very much
Please check the Code of GUI and the imgs down.
<?xml version="1.0" encoding="UTF-8"?>
<?import de.riconn.fx_ebm_control.gui.views.abgleich.*?>
<?import de.riconn.fx_ebm_control.gui.views.arzt_aktuell.*?>
<?import de.riconn.fx_ebm_control.gui.views.ebm.*?>
<?import de.riconn.fx_ebm_control.gui.views.frequenz.*?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.effect.Glow?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity"
minHeight="-Infinity" minWidth="-Infinity" prefHeight="900.0"
prefWidth="1230.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="de.riconn.fx_ebm_control.gui.WpdlTxtControler">
<center>
<TabPane prefHeight="200.0" prefWidth="200.0"
tabClosingPolicy="UNAVAILABLE" BorderPane.alignment="CENTER">
<tabs>
<Tab fx:id="tab_patient" onSelectionChanged="#tab_Patienten_Selected"
text="Patientenliste">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0"
prefWidth="200.0">
<children>
<BorderPane layoutX="107.0" layoutY="53.0"
prefHeight="346.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0"
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="0.0">
<top>
<Button fx:id="btn_PatientenOpen" mnemonicParsing="false"
onAction="#openPatientenListe" text="Patientenliste öffnen.."
BorderPane.alignment="CENTER" />
</top>
<center>
<ArztAktuellTableView fx:id="tv_patientContainer"
prefHeight="494.0" prefWidth="829.0" BorderPane.alignment="CENTER" />
</center>
</BorderPane>
</children>
</AnchorPane>
</content>
</Tab>
<Tab fx:id="tab_frequenz" onSelectionChanged="#tab_Frequenz_Selected"
text="Frequenztabelle">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0"
prefWidth="200.0">
<children>
<BorderPane layoutX="109.0" layoutY="49.0"
prefHeight="346.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0"
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="0.0">
<top>
<Button fx:id="btn_FrequenzOpen" mnemonicParsing="false"
onAction="#openFrequenzFile" text="Frequenztabelle öffnen..."
BorderPane.alignment="CENTER" />
</top>
<center>
<FrequenzTableView fx:id="tv_frequenzContainer"
prefHeight="494.0" prefWidth="829.0" BorderPane.alignment="CENTER_RIGHT" />
</center>
</BorderPane>
</children>
</AnchorPane>
</content>
</Tab>
<Tab fx:id="tab_abgleich" onSelectionChanged="#tab_Abgleich_Selected"
text="Abgleichsliste">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0"
prefWidth="200.0">
<children>
<BorderPane layoutX="69.0" layoutY="51.0" prefHeight="346.0"
prefWidth="600.0" AnchorPane.bottomAnchor="0.0"
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="0.0">
<top>
<HBox alignment="TOP_RIGHT" spacing="10.0">
<Button fx:id="btn_AbgleichToPdf" mnemonicParsing="false"
onAction="#viewAbgleichAsPdf" text="Als PDF öffnen..."
BorderPane.alignment="CENTER" />
<BorderPane.margin>
<Insets right="10.0" />
</BorderPane.margin>
</HBox>
</top>
<center>
<AbgleichTableView fx:id="tv_abgleichContainer"
prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER" />
</center>
</BorderPane>
</children>
</AnchorPane>
</content>
</Tab>
<Tab fx:id="tab_EBM" onSelectionChanged="#tab_EBM_Selected"
text="EBM Liste">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0"
prefWidth="200.0">
<children>
<BorderPane layoutX="489.0" layoutY="229.0"
prefHeight="829.0" prefWidth="1200.0" AnchorPane.bottomAnchor="0.0"
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="0.0">
<top>
<HBox alignment="TOP_RIGHT" spacing="10.0">
<Button fx:id="btn_minus_ebm" mnemonicParsing="false"
onAction="#delete_ebm" text="-">
</Button>
<Button fx:id="btn_plus_ebm" mnemonicParsing="false"
onAction="#add_ebm" text="+">
</Button>
<BorderPane.margin>
<Insets right="10.0" />
</BorderPane.margin>
</HBox>
</top>
<center>
<EBMTableView fx:id="tv_EBMContainer" editable="true"
prefHeight="200.0" prefWidth="200.0" tableMenuButtonVisible="true"
BorderPane.alignment="CENTER" />
</center>
</BorderPane>
</children>
</AnchorPane>
</content>
</Tab>
</tabs>
</TabPane>
</center>
<top>
<MenuBar prefHeight="0.0" prefWidth="878.0"
BorderPane.alignment="CENTER">
<menus>
<Menu mnemonicParsing="false" text="File">
<items>
<MenuItem mnemonicParsing="false" onAction="#openFrequenzFile"
text="Frequenztabelle öffnen..." />
<MenuItem mnemonicParsing="false" onAction="#openPatientenListe"
text="Patientenliste öffnen..." />
<MenuItem mnemonicParsing="false" onAction="#close" text="Close" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Edit">
<items>
<MenuItem fx:id="m_add_ebm" disable="true" mnemonicParsing="false" onAction="#add_ebm"
text="hinzufügen" />
<MenuItem fx:id="m_delete_ebm" disable="true" mnemonicParsing="false" onAction="#delete_ebm"
text="löschen" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Abgleich">
<items>
<MenuItem fx:id="m_viewAbgleichAsPdf" disable="true" mnemonicParsing="false"
onAction="#viewAbgleichAsPdf" text="Als PDF öffnen" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Help">
<items>
<MenuItem mnemonicParsing="false" onAction="#openAboutDialog"
text="About" />
</items>
</Menu>
</menus>
</MenuBar>
</top>
</BorderPane>
JavaFX Scene Builder structure
windows with scrollButton
windows without scrollButton after minimizing
Problem Solved, just change the first BorderPane Params like this ->
<BorderPane maxHeight="0" maxWidth="0"
minHeight="0" minWidth="0" prefHeight="0"
prefWidth="1230.0" xmlns="http://javafx.com/javafx/8.0.111"
xmlns:fx="http://javafx.com/fxml/1"

JAvaFX elements resize to fit Window

I am just trying out JavaFX and am forcing my way into it because it is suppose to be the future. The problem I have is that the components don't resize with the screen. I tried to change the HBoxz HPane constraints but they seem to mess it all up.
Here is my FXML file.
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<?import org.kordamp.ikonli.javafx.FontIcon?>
<AnchorPane id="AnchorPane" prefHeight="671.0" prefWidth="1020.0" stylesheets="#../../../resources/css/MainCSS.css" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.arpentechnologies.software.core.paneladmin.gestionroles.FXMLGestionRolesController">
<children>
<Button id="backButton" fx:id="volverPanelAdminButton" layoutX="14.0" layoutY="14.0" mnemonicParsing="false" onAction="#onClickVolverInicio" prefHeight="56.0" prefWidth="54.0" styleClass="backButton" stylesheets="#../../../resources/css/MainCSS.css" AnchorPane.leftAnchor="8.0">
<graphic>
<FontIcon iconLiteral="mdi-keyboard-backspace" iconSize="30" wrappingWidth="30.0" />
</graphic>
</Button>
<StackPane layoutX="14.0" layoutY="83.0" prefHeight="50.0" prefWidth="253.0" AnchorPane.leftAnchor="8.0">
<children>
<TextField prefHeight="45.0" prefWidth="283.0" promptText="Buscar...">
<font>
<Font size="18.0" />
</font>
</TextField>
</children>
</StackPane>
<StackPane layoutX="267.0" layoutY="83.0" prefHeight="50.0" prefWidth="50.0">
<children>
<FontIcon iconLiteral="mdi-send" iconSize="36" text="" />
</children>
</StackPane>
<StackPane layoutX="860.0" layoutY="77.0" prefHeight="62.0" prefWidth="200.0" AnchorPane.rightAnchor="8.0">
<children>
<Button fx:id="anadirRolButton" mnemonicParsing="false" onAction="#onClickAnadirRol" prefHeight="39.0" prefWidth="231.0" text=" Añadir Rol">
<font>
<Font size="18.0" />
</font>
<graphic>
<FontIcon iconLiteral="mdi-account-plus" iconSize="26" />
</graphic>
</Button>
</children>
</StackPane>
<HBox layoutX="14.0" layoutY="152.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="511.0" prefWidth="1060.0">
<children>
<TableView prefHeight="495.0" prefWidth="1049.0" HBox.hgrow="ALWAYS">
<columns>
<TableColumn prefWidth="75.0" text="Nombre" />
<TableColumn prefWidth="75.0" text="Rol Padre" />
<TableColumn prefWidth="75.0" text="Módulos" />
<TableColumn prefWidth="75.0" text="Permisos" />
<TableColumn prefWidth="75.0" text="Editar" />
<TableColumn prefWidth="75.0" text="Borrar" />
</columns>
</TableView>
</children>
</HBox>
<Text layoutX="425.0" layoutY="65.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Gestión de Roles" wrappingWidth="224.0546875">
<font>
<Font size="30.0" />
</font>
</Text>
</children>
</AnchorPane>
I tried making some changes to your fxml file for obtain a responsive layout to achieve your needs
The resizable tableView and the text moves from the center to the
left
Change the Anchor Constraints of HBox which contain the tableView
Put Gestión de Roles in HBox
This is your FXML file after changes :
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<AnchorPane id="AnchorPane" prefHeight="671.0" prefWidth="1020.0" stylesheets="#../../../resources/css/MainCSS.css" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Button id="backButton" fx:id="volverPanelAdminButton" layoutX="14.0" layoutY="14.0" mnemonicParsing="false" prefHeight="56.0" prefWidth="54.0" styleClass="backButton" stylesheets="#../../../resources/css/MainCSS.css" AnchorPane.leftAnchor="8.0">
<graphic>
</graphic>
</Button>
<StackPane layoutX="14.0" layoutY="83.0" prefHeight="50.0" prefWidth="253.0" AnchorPane.leftAnchor="8.0">
<children>
<TextField prefHeight="45.0" prefWidth="283.0" promptText="Buscar...">
<font>
<Font size="18.0" />
</font>
</TextField>
</children>
</StackPane>
<StackPane layoutX="267.0" layoutY="83.0" prefHeight="50.0" prefWidth="50.0">
<children>
</children>
</StackPane>
<StackPane layoutX="860.0" layoutY="77.0" prefHeight="62.0" prefWidth="200.0" AnchorPane.rightAnchor="8.0">
<children>
<Button fx:id="anadirRolButton" mnemonicParsing="false" prefHeight="39.0" prefWidth="231.0" text=" Añadir Rol">
<font>
<Font size="18.0" />
</font>
<graphic>
</graphic>
</Button>
</children>
</StackPane>
<HBox layoutX="14.0" layoutY="152.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="511.0" prefWidth="1060.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<children>
<TableView prefHeight="495.0" prefWidth="1049.0" HBox.hgrow="ALWAYS">
<columns>
<TableColumn prefWidth="75.0" text="Nombre" />
<TableColumn prefWidth="75.0" text="Rol Padre" />
<TableColumn prefWidth="75.0" text="Módulos" />
<TableColumn prefWidth="75.0" text="Permisos" />
<TableColumn prefWidth="75.0" text="Editar" />
<TableColumn prefWidth="75.0" text="Borrar" />
</columns>
</TableView>
</children>
</HBox>
<HBox alignment="CENTER" layoutX="174.0" layoutY="14.0" prefHeight="100.0" prefWidth="200.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Gestión de Roles" wrappingWidth="224.0546875" HBox.hgrow="ALWAYS">
<font>
<Font size="30.0" />
</font>
</Text>
</children>
</HBox>
</children>
</AnchorPane>
I've altered AnchorPane's HBox Constraints to stay fixed, thus ensuring responsiveness
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<AnchorPane id="AnchorPane" prefHeight="671.0" prefWidth="1020.0" stylesheets="#../../../resources/css/MainCSS.css" xmlns="http://javafx.com/javafx/8.0.102" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.arpentechnologies.software.core.paneladmin.gestionroles.FXMLGestionRolesController">
<children>
<Button id="backButton" fx:id="volverPanelAdminButton" layoutX="14.0" layoutY="14.0" mnemonicParsing="false" onAction="#onClickVolverInicio" prefHeight="56.0" prefWidth="54.0" styleClass="backButton" stylesheets="#../../../resources/css/MainCSS.css" AnchorPane.leftAnchor="8.0">
<graphic>
<FontIcon iconLiteral="mdi-keyboard-backspace" iconSize="30" wrappingWidth="30.0" />
</graphic>
</Button>
<StackPane layoutX="14.0" layoutY="83.0" prefHeight="50.0" prefWidth="253.0" AnchorPane.leftAnchor="8.0">
<children>
<TextField prefHeight="45.0" prefWidth="283.0" promptText="Buscar...">
<font>
<Font size="18.0" />
</font>
</TextField>
</children>
</StackPane>
<StackPane layoutX="267.0" layoutY="83.0" prefHeight="50.0" prefWidth="50.0">
<children>
<FontIcon iconLiteral="mdi-send" iconSize="36" text="?" />
</children>
</StackPane>
<StackPane layoutX="860.0" layoutY="77.0" prefHeight="62.0" prefWidth="200.0" AnchorPane.rightAnchor="8.0">
<children>
<Button fx:id="anadirRolButton" mnemonicParsing="false" onAction="#onClickAnadirRol" prefHeight="39.0" prefWidth="231.0" text=" A�adir Rol">
<font>
<Font size="18.0" />
</font>
<graphic>
<FontIcon iconLiteral="mdi-account-plus" iconSize="26" />
</graphic>
</Button>
</children>
</StackPane>
<HBox layoutX="14.0" layoutY="152.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="511.0" prefWidth="1060.0" AnchorPane.bottomAnchor="8.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="152.0">
<children>
<TableView prefHeight="495.0" prefWidth="1049.0" HBox.hgrow="ALWAYS">
<columns>
<TableColumn prefWidth="75.0" text="Nombre" />
<TableColumn prefWidth="75.0" text="Rol Padre" />
<TableColumn prefWidth="75.0" text="M�dulos" />
<TableColumn prefWidth="75.0" text="Permisos" />
<TableColumn prefWidth="75.0" text="Editar" />
<TableColumn prefWidth="75.0" text="Borrar" />
</columns>
</TableView>
</children>
</HBox>
<Text layoutX="425.0" layoutY="65.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Gesti�n de Roles" wrappingWidth="224.0546875">
<font>
<Font size="30.0" />
</font>
</Text>
</children>
</AnchorPane>
You can also add a ScrollPane
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<AnchorPane id="AnchorPane" prefHeight="671.0" prefWidth="1020.0" stylesheets="#../../../resources/css/MainCSS.css" xmlns="http://javafx.com/javafx/8.0.102" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.arpentechnologies.software.core.paneladmin.gestionroles.FXMLGestionRolesController">
<children>
<ScrollPane prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="670.0" prefWidth="1005.0">
<children>
<HBox layoutX="389.0" layoutY="30.0">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Gesti�n de Roles" wrappingWidth="241.0546875" HBox.hgrow="NEVER">
<font>
<Font size="30.0" />
</font>
</Text>
</children>
</HBox>
<Button id="backButton" fx:id="volverPanelAdminButton" layoutX="14.0" layoutY="25.0" mnemonicParsing="false" onAction="#onClickVolverInicio" prefHeight="50.0" prefWidth="115.0" styleClass="backButton" stylesheets="#../../../resources/css/MainCSS.css" AnchorPane.leftAnchor="14.0">
<graphic>
<FontIcon iconLiteral="mdi-keyboard-backspace" iconSize="30" wrappingWidth="30.0" />
</graphic>
</Button>
<StackPane layoutX="14.0" layoutY="87.0" prefHeight="50.0" prefWidth="253.0" AnchorPane.leftAnchor="14.0">
<children>
<TextField promptText="Buscar...">
<font>
<Font size="18.0" />
</font>
</TextField>
</children>
</StackPane>
<StackPane layoutX="280.0" layoutY="87.0" prefHeight="50.0" prefWidth="50.0">
<children>
<FontIcon iconLiteral="mdi-send" iconSize="36" text="?" />
</children>
</StackPane>
<StackPane layoutX="784.0" layoutY="81.0" prefHeight="62.0" prefWidth="200.0" AnchorPane.rightAnchor="21.0">
<children>
<Button fx:id="anadirRolButton" mnemonicParsing="false" onAction="#onClickAnadirRol" text=" A�adir Rol">
<font>
<Font size="18.0" />
</font>
<graphic>
<FontIcon iconLiteral="mdi-account-plus" iconSize="26" />
</graphic>
</Button>
</children>
</StackPane>
<HBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" AnchorPane.bottomAnchor="8.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="152.0">
<children>
<TableView HBox.hgrow="ALWAYS">
<columns>
<TableColumn prefWidth="75.0" text="Nombre" />
<TableColumn prefWidth="75.0" text="Rol Padre" />
<TableColumn prefWidth="75.0" text="M�dulos" />
<TableColumn prefWidth="75.0" text="Permisos" />
<TableColumn prefWidth="75.0" text="Editar" />
<TableColumn prefWidth="75.0" text="Borrar" />
</columns>
</TableView>
</children>
</HBox>
</children>
</AnchorPane>
</content>
</ScrollPane>
</children>
</AnchorPane>

Is possible for javafx.scene.control.ScrollPane to take the remaining space in a Tab panel?

I have a fxml file containing a ScrollPanel, that I use to display an image, inside a TabPanel:
<Tab text="Example" fx:id="liveTab" fx:controller="me.example.ExampleController" xmlns:fx="http://javafx.com/fxml">
<content>
<HBox prefHeight="600.0" prefWidth="1200.0">
<children>
<FlowPane prefHeight="600.0" prefWidth="400.0">
<children>
<ScrollPane prefHeight="580.0" prefWidth="200.0">
<content>
<ListView fx:id="listView" prefHeight="580.0" prefWidth="190.0">
<items>
<FXCollections fx:factory="observableArrayList">
</FXCollections>
</items>
</ListView>
</content>
</ScrollPane>
<ScrollPane prefHeight="580.0" prefWidth="200.0">
<content>
<ListView prefHeight="580.0" prefWidth="190.0">
<items>
<FXCollections fx:factory="observableArrayList">
</FXCollections>
</items>
</ListView>
</content>
</ScrollPane>
<HBox alignment="BOTTOM_RIGHT" prefHeight="20.0" prefWidth="400.0" spacing="10.0" GridPane.columnIndex="0" GridPane.rowIndex="2">
<Button text="Add"/>
<Button text="Remove"/>
</HBox>
</children>
</FlowPane>
<VBox>
<children>
<ScrollPane fitToHeight="true" fitToWidth="true">
<content>
<ImageView fx:id="imageContainer" pickOnBounds="true" preserveRatio="true">
<Image url="file:/C:/Users/Public/Pictures/Sample%20Pictures/Koala.jpg" preserveRatio="true" />
</ImageView>
</content>
</ScrollPane>
</children>
</VBox>
</children>
</HBox>
</content>
</Tab>
I want the ImageView to take all the remaining space of the containing tab, I have tried to use fitToHeight="true" fitToWidth="true", and change from a FlowPane to a VBox but I keep getting this:
Does
<ScrollPane fx:id="scrollPane" fitToHeight="true" fitToWidth="true">
...
help?
Ok, I figured out how to get the desired behavior. Using AnchorPane one can force the children nodes to take the space relative to the parent. I share the code just in case someone finds it useful:
<Tab text="Example" fx:id="liveTab" fx:controller="me.example.ExampleController" xmlns:fx="http://javafx.com/fxml">
<content>
<AnchorPane prefHeight="600.0" prefWidth="1200.0">
<children>
<FlowPane prefHeight="600.0" prefWidth="400.0">
<children>
<ScrollPane prefHeight="580.0" prefWidth="200.0">
<content>
<ListView fx:id="listView" prefHeight="580.0" prefWidth="190.0">
<items>
<FXCollections fx:factory="observableArrayList">
</FXCollections>
</items>
</ListView>
</content>
</ScrollPane>
<ScrollPane prefHeight="580.0" prefWidth="200.0">
<content>
<ListView prefHeight="580.0" prefWidth="190.0">
<items>
<FXCollections fx:factory="observableArrayList">
</FXCollections>
</items>
</ListView>
</content>
</ScrollPane>
<HBox alignment="BOTTOM_RIGHT" prefHeight="20.0" prefWidth="400.0" spacing="10.0" GridPane.columnIndex="0" GridPane.rowIndex="2">
<Button text="Add"/>
<Button text="Remove"/>
</HBox>
</children>
</FlowPane>
<AnchorPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="400.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<ScrollPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<content>
<ImageView fx:id="imageContainer" pickOnBounds="true" preserveRatio="true">
<Image url="file:/C:/Users/Public/Pictures/Sample%20Pictures/Koala.jpg" preserveRatio="true" />
</ImageView>
</content>
</ScrollPane>
</AnchorPane>
</children>
</AnchorPane>
</content>
</Tab>
and the result:

Resources