Fixed scene resizing when a new page happens to load.

main
Fan-Wu Yang 9 years ago
parent dcf92b4333
commit 2dd4182799

@ -19,9 +19,10 @@ import java.io.InputStream;
public class Main extends Application {
private Stage primaryStage;
private Scene base;
private Parent base;
private BaseController baseController;
private Session session;
private Scene scene = null;
public void start(Stage stage) throws Exception {
this.primaryStage = stage;
@ -30,7 +31,7 @@ public class Main extends Application {
//load up base pane
FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource("scenes/base.fxml"));
Parent root = loader.load();
base = new Scene(root, SceneCode.prefWidth, SceneCode.prefHeight);
base = root;
baseController = (BaseController) loader.getController();
baseController.setParent(this);
@ -38,6 +39,8 @@ public class Main extends Application {
//set up stage
stage.setTitle("UC RSS");
stage.setMinHeight(400);
stage.setMinWidth(600);
stage.show();
}
@ -57,12 +60,19 @@ public class Main extends Application {
} finally {
in.close();
}
Scene scene = null;
if (fxml.isLoadMenu()){
scene = base;
if (scene == null){
scene = new Scene(base, SceneCode.prefWidth, SceneCode.prefHeight);
}else{
scene.setRoot(base);
}
baseController.setContent(page);
}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);
Controller controller = loader.getController();

@ -5,7 +5,6 @@
<?import java.lang.*?>
<?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">
<children>
<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>
<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 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 vgrow="SOMETIMES" />
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="40.0" minHeight="10.0" prefHeight="40.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
</rowConstraints>
<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 size="18.0" />
</font>
</Label>
<Label text="Model:" GridPane.columnIndex="1" GridPane.halignment="LEFT" GridPane.rowIndex="1" />
<Label text="Colour:" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<Label text="License Plate:" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<Label text="Year:" GridPane.columnIndex="1" GridPane.rowIndex="4" />
<Label text="Number of Seats:" GridPane.columnIndex="1" GridPane.rowIndex="5" />
<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" />
<TextField fx:id="model" GridPane.columnIndex="2" GridPane.rowIndex="1" />
<TextField fx:id="colour" GridPane.columnIndex="2" GridPane.rowIndex="2" />
<TextField fx:id="license" GridPane.columnIndex="2" GridPane.rowIndex="3" />
<TextField fx:id="year" GridPane.columnIndex="2" GridPane.rowIndex="4" />
<TextField fx:id="numSeats" GridPane.columnIndex="2" GridPane.rowIndex="5" />
<Label text="Model:" GridPane.columnIndex="1" GridPane.halignment="LEFT" GridPane.rowIndex="2" />
<Label text="Colour:" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<Label text="License Plate:" 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="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="2" />
<TextField fx:id="colour" 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="5" />
<TextField fx:id="numSeats" GridPane.columnIndex="2" GridPane.rowIndex="6" />
</children>
</GridPane>
</children>

@ -5,7 +5,6 @@
<?import java.lang.*?>
<?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">
<children>
<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>
<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 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 vgrow="SOMETIMES" />
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="40.0" minHeight="10.0" prefHeight="40.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
<RowConstraints vgrow="SOMETIMES" />
</rowConstraints>
<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 size="18.0" />
</font>
</Label>
<Label text="Model:" GridPane.columnIndex="1" GridPane.halignment="LEFT" GridPane.rowIndex="1" />
<Label text="Colour:" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<Label text="License Plate:" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<Label text="Year:" GridPane.columnIndex="1" GridPane.rowIndex="4" />
<Label text="Number of Seats:" GridPane.columnIndex="1" GridPane.rowIndex="5" />
<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" />
<TextField fx:id="model" GridPane.columnIndex="2" GridPane.rowIndex="1" />
<TextField fx:id="colour" GridPane.columnIndex="2" GridPane.rowIndex="2" />
<TextField fx:id="license" GridPane.columnIndex="2" GridPane.rowIndex="3" />
<TextField fx:id="year" GridPane.columnIndex="2" GridPane.rowIndex="4" />
<TextField fx:id="numSeats" GridPane.columnIndex="2" GridPane.rowIndex="5" />
<Label text="Model:" GridPane.columnIndex="1" GridPane.halignment="LEFT" GridPane.rowIndex="2" />
<Label text="Colour:" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<Label text="License Plate:" 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="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="2" />
<TextField fx:id="colour" 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="5" />
<TextField fx:id="numSeats" GridPane.columnIndex="2" GridPane.rowIndex="6" />
</children>
</GridPane>
</children>

Loading…
Cancel
Save