Fixed scene resizing when a new page happens to load.
This commit is contained in:
@@ -19,9 +19,10 @@ import java.io.InputStream;
|
|||||||
public class Main extends Application {
|
public class Main extends Application {
|
||||||
|
|
||||||
private Stage primaryStage;
|
private Stage primaryStage;
|
||||||
private Scene base;
|
private Parent base;
|
||||||
private BaseController baseController;
|
private BaseController baseController;
|
||||||
private Session session;
|
private Session session;
|
||||||
|
private Scene scene = null;
|
||||||
|
|
||||||
public void start(Stage stage) throws Exception {
|
public void start(Stage stage) throws Exception {
|
||||||
this.primaryStage = stage;
|
this.primaryStage = stage;
|
||||||
@@ -30,7 +31,7 @@ public class Main extends Application {
|
|||||||
//load up base pane
|
//load up base pane
|
||||||
FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource("scenes/base.fxml"));
|
FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource("scenes/base.fxml"));
|
||||||
Parent root = loader.load();
|
Parent root = loader.load();
|
||||||
base = new Scene(root, SceneCode.prefWidth, SceneCode.prefHeight);
|
base = root;
|
||||||
baseController = (BaseController) loader.getController();
|
baseController = (BaseController) loader.getController();
|
||||||
baseController.setParent(this);
|
baseController.setParent(this);
|
||||||
|
|
||||||
@@ -38,6 +39,8 @@ public class Main extends Application {
|
|||||||
|
|
||||||
//set up stage
|
//set up stage
|
||||||
stage.setTitle("UC RSS");
|
stage.setTitle("UC RSS");
|
||||||
|
stage.setMinHeight(400);
|
||||||
|
stage.setMinWidth(600);
|
||||||
stage.show();
|
stage.show();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -57,12 +60,19 @@ public class Main extends Application {
|
|||||||
} finally {
|
} finally {
|
||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
Scene scene = null;
|
|
||||||
if (fxml.isLoadMenu()){
|
if (fxml.isLoadMenu()){
|
||||||
scene = base;
|
if (scene == null){
|
||||||
|
scene = new Scene(base, SceneCode.prefWidth, SceneCode.prefHeight);
|
||||||
|
}else{
|
||||||
|
scene.setRoot(base);
|
||||||
|
}
|
||||||
baseController.setContent(page);
|
baseController.setContent(page);
|
||||||
}else {
|
}else {
|
||||||
scene = new Scene(page, SceneCode.prefWidth, SceneCode.prefHeight);
|
if (scene == null) {
|
||||||
|
scene = new Scene(page, SceneCode.prefWidth, SceneCode.prefHeight);
|
||||||
|
}else{
|
||||||
|
scene.setRoot(page);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
primaryStage.setScene(scene);
|
primaryStage.setScene(scene);
|
||||||
Controller controller = loader.getController();
|
Controller controller = loader.getController();
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
<?import java.lang.*?>
|
<?import java.lang.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
|
|
||||||
<AnchorPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="controllers.AddRideController">
|
<AnchorPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="controllers.AddRideController">
|
||||||
<children>
|
<children>
|
||||||
<GridPane layoutX="154.0" layoutY="68.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<GridPane layoutX="154.0" layoutY="68.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
@@ -16,32 +15,33 @@
|
|||||||
<ColumnConstraints hgrow="SOMETIMES" />
|
<ColumnConstraints hgrow="SOMETIMES" />
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
<rowConstraints>
|
<rowConstraints>
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints vgrow="SOMETIMES" />
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="40.0" minHeight="10.0" prefHeight="40.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints vgrow="SOMETIMES" />
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<children>
|
<children>
|
||||||
<Label text="Add a Ride" GridPane.columnSpan="4" GridPane.halignment="CENTER" GridPane.valignment="CENTER">
|
<Label text="Add a Ride" GridPane.columnSpan="4" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER">
|
||||||
<font>
|
<font>
|
||||||
<Font size="18.0" />
|
<Font size="18.0" />
|
||||||
</font>
|
</font>
|
||||||
</Label>
|
</Label>
|
||||||
<Label text="Model:" GridPane.columnIndex="1" GridPane.halignment="LEFT" GridPane.rowIndex="1" />
|
<Label text="Model:" GridPane.columnIndex="1" GridPane.halignment="LEFT" GridPane.rowIndex="2" />
|
||||||
<Label text="Colour:" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
<Label text="Colour:" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
||||||
<Label text="License Plate:" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
<Label text="License Plate:" GridPane.columnIndex="1" GridPane.rowIndex="4" />
|
||||||
<Label text="Year:" GridPane.columnIndex="1" GridPane.rowIndex="4" />
|
<Label text="Year:" GridPane.columnIndex="1" GridPane.rowIndex="5" />
|
||||||
<Label text="Number of Seats:" GridPane.columnIndex="1" GridPane.rowIndex="5" />
|
<Label text="Number of Seats:" GridPane.columnIndex="1" GridPane.rowIndex="6" />
|
||||||
<Button mnemonicParsing="false" onAction="#addRide" prefHeight="25.0" prefWidth="187.0" text="Submit" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.halignment="CENTER" GridPane.hgrow="ALWAYS" GridPane.rowIndex="6" />
|
<Button mnemonicParsing="false" onAction="#addRide" prefHeight="25.0" prefWidth="187.0" text="Submit" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.halignment="CENTER" GridPane.hgrow="ALWAYS" GridPane.rowIndex="7" />
|
||||||
<TextField fx:id="model" GridPane.columnIndex="2" GridPane.rowIndex="1" />
|
<TextField fx:id="model" GridPane.columnIndex="2" GridPane.rowIndex="2" />
|
||||||
<TextField fx:id="colour" GridPane.columnIndex="2" GridPane.rowIndex="2" />
|
<TextField fx:id="colour" GridPane.columnIndex="2" GridPane.rowIndex="3" />
|
||||||
<TextField fx:id="license" GridPane.columnIndex="2" GridPane.rowIndex="3" />
|
<TextField fx:id="license" GridPane.columnIndex="2" GridPane.rowIndex="4" />
|
||||||
<TextField fx:id="year" GridPane.columnIndex="2" GridPane.rowIndex="4" />
|
<TextField fx:id="year" GridPane.columnIndex="2" GridPane.rowIndex="5" />
|
||||||
<TextField fx:id="numSeats" GridPane.columnIndex="2" GridPane.rowIndex="5" />
|
<TextField fx:id="numSeats" GridPane.columnIndex="2" GridPane.rowIndex="6" />
|
||||||
</children>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</children>
|
</children>
|
||||||
|
|||||||
Binary file not shown.
@@ -5,7 +5,6 @@
|
|||||||
<?import java.lang.*?>
|
<?import java.lang.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
|
|
||||||
<AnchorPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="controllers.AddRideController">
|
<AnchorPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="controllers.AddRideController">
|
||||||
<children>
|
<children>
|
||||||
<GridPane layoutX="154.0" layoutY="68.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<GridPane layoutX="154.0" layoutY="68.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
@@ -16,32 +15,33 @@
|
|||||||
<ColumnConstraints hgrow="SOMETIMES" />
|
<ColumnConstraints hgrow="SOMETIMES" />
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
<rowConstraints>
|
<rowConstraints>
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints vgrow="SOMETIMES" />
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="40.0" minHeight="10.0" prefHeight="40.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints vgrow="SOMETIMES" />
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<children>
|
<children>
|
||||||
<Label text="Add a Ride" GridPane.columnSpan="4" GridPane.halignment="CENTER" GridPane.valignment="CENTER">
|
<Label text="Add a Ride" GridPane.columnSpan="4" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER">
|
||||||
<font>
|
<font>
|
||||||
<Font size="18.0" />
|
<Font size="18.0" />
|
||||||
</font>
|
</font>
|
||||||
</Label>
|
</Label>
|
||||||
<Label text="Model:" GridPane.columnIndex="1" GridPane.halignment="LEFT" GridPane.rowIndex="1" />
|
<Label text="Model:" GridPane.columnIndex="1" GridPane.halignment="LEFT" GridPane.rowIndex="2" />
|
||||||
<Label text="Colour:" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
<Label text="Colour:" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
||||||
<Label text="License Plate:" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
<Label text="License Plate:" GridPane.columnIndex="1" GridPane.rowIndex="4" />
|
||||||
<Label text="Year:" GridPane.columnIndex="1" GridPane.rowIndex="4" />
|
<Label text="Year:" GridPane.columnIndex="1" GridPane.rowIndex="5" />
|
||||||
<Label text="Number of Seats:" GridPane.columnIndex="1" GridPane.rowIndex="5" />
|
<Label text="Number of Seats:" GridPane.columnIndex="1" GridPane.rowIndex="6" />
|
||||||
<Button mnemonicParsing="false" onAction="#addRide" prefHeight="25.0" prefWidth="187.0" text="Submit" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.halignment="CENTER" GridPane.hgrow="ALWAYS" GridPane.rowIndex="6" />
|
<Button mnemonicParsing="false" onAction="#addRide" prefHeight="25.0" prefWidth="187.0" text="Submit" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.halignment="CENTER" GridPane.hgrow="ALWAYS" GridPane.rowIndex="7" />
|
||||||
<TextField fx:id="model" GridPane.columnIndex="2" GridPane.rowIndex="1" />
|
<TextField fx:id="model" GridPane.columnIndex="2" GridPane.rowIndex="2" />
|
||||||
<TextField fx:id="colour" GridPane.columnIndex="2" GridPane.rowIndex="2" />
|
<TextField fx:id="colour" GridPane.columnIndex="2" GridPane.rowIndex="3" />
|
||||||
<TextField fx:id="license" GridPane.columnIndex="2" GridPane.rowIndex="3" />
|
<TextField fx:id="license" GridPane.columnIndex="2" GridPane.rowIndex="4" />
|
||||||
<TextField fx:id="year" GridPane.columnIndex="2" GridPane.rowIndex="4" />
|
<TextField fx:id="year" GridPane.columnIndex="2" GridPane.rowIndex="5" />
|
||||||
<TextField fx:id="numSeats" GridPane.columnIndex="2" GridPane.rowIndex="5" />
|
<TextField fx:id="numSeats" GridPane.columnIndex="2" GridPane.rowIndex="6" />
|
||||||
</children>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</children>
|
</children>
|
||||||
|
|||||||
Reference in New Issue
Block a user