У меня проблема при попытке закрыть открытую панель навигации, размер моей центральной панели изменился, и я не знаю, как это исправить.
Экран при запуске экрана
Экран, когда отображается навигационная панель
Экран, когда возникает проблема, ящик не виден, но размер центральной панели изменяется
HomePageController
package controllers;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXDrawer;
import com.jfoenix.controls.JFXHamburger;
import com.jfoenix.transitions.hamburger.HamburgerBasicCloseTransition;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
public class HomePageController implements Initializable {
@FXML
private BorderPane borderPane;
@FXML
private AnchorPane topAnchorPane;
@FXML
private JFXButton btn2;
@FXML
private JFXDrawer drawer;
@FXML
private JFXButton btn3;
@FXML
private JFXButton btn1;
@FXML
private JFXHamburger hamburger;
@Override
public void initialize(URL location, ResourceBundle resources) {
try {
VBox box = FXMLLoader.load(getClass().getResource("/resources/view/homePageDrawerContent.fxml"));
drawer.setSidePane(box);
HamburgerBasicCloseTransition transition = new HamburgerBasicCloseTransition(hamburger);
transition.setRate(-1);
hamburger.addEventHandler(MouseEvent.MOUSE_PRESSED, (e) -> {
transition.setRate(transition.getRate() * -1);
transition.play();
if (drawer.isShown()) {
drawer.close();
} else {
drawer.open();
}
});
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
Файл fxml домашней страницы
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import com.jfoenix.controls.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<BorderPane fx:id="borderPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="491.0" prefWidth="783.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="controllers.HomePageController">
<top>
<AnchorPane fx:id="topAnchorPane" prefHeight="79.0" prefWidth="783.0" style="-fx-background-color: gray;" BorderPane.alignment="CENTER">
<children>
<HBox layoutX="553.0" layoutY="2.0" spacing="7.0" AnchorPane.rightAnchor="24.0">
<children>
<JFXButton fx:id="btn1" prefHeight="60.0" prefWidth="60.0" style="-fx-background-color: red;" text="1" />
<JFXButton fx:id="btn2" prefHeight="60.0" prefWidth="60.0" style="-fx-background-color: green;" text="2">
<HBox.margin>
<Insets />
</HBox.margin>
</JFXButton>
<JFXButton fx:id="btn3" prefHeight="60.0" prefWidth="60.0" style="-fx-background-color: blue;" text="3" />
</children>
<padding>
<Insets bottom="6.0" left="6.0" right="6.0" top="6.0" />
</padding>
</HBox>
<JFXHamburger fx:id="hamburger" layoutX="14.0" layoutY="30.0" />
</children>
</AnchorPane>
</top>
<left>
<JFXDrawer fx:id="drawer" defaultDrawerSize="150.0" BorderPane.alignment="CENTER" />
</left>
<center>
<StackPane prefHeight="150.0" prefWidth="200.0" style="-fx-border-color: black;" BorderPane.alignment="CENTER">
<children>
<StackPane prefHeight="150.0" prefWidth="200.0">
<children>
<Pane maxHeight="130.0" maxWidth="200.0" prefHeight="112.0" prefWidth="200.0" style="-fx-background-color: lightgray;">
<StackPane.margin>
<Insets top="40.0" />
</StackPane.margin>
</Pane>
<JFXTextField alignment="TOP_LEFT" maxWidth="150.0" promptText="unesite neki parametar" />
<JFXButton text="Pretraži kartoteku" StackPane.alignment="CENTER">
<StackPane.margin>
<Insets top="100.0" />
</StackPane.margin>
</JFXButton>
</children>
</StackPane>
</children>
</StackPane>
</center>
</BorderPane>