Added Sample Loading for the GUI
This commit is contained in:
Binary file not shown.
@@ -1,12 +1,21 @@
|
|||||||
package seng202.group9.Controller;
|
package seng202.group9.Controller;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.fxml.Initializable;
|
||||||
|
import javafx.fxml.JavaFXBuilderFactory;
|
||||||
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.Menu;
|
||||||
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.BorderPane;
|
import javafx.scene.layout.BorderPane;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import seng202.group9.GUI.MainMenuBar;
|
import seng202.group9.GUI.MenuController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main Application frame of the Flight Data Analyser.
|
* Main Application frame of the Flight Data Analyser.
|
||||||
@@ -16,6 +25,7 @@ public class App extends Application
|
|||||||
{
|
{
|
||||||
private ArrayList<Dataset> Datasets = new ArrayList<Dataset>();
|
private ArrayList<Dataset> Datasets = new ArrayList<Dataset>();
|
||||||
private Dataset currentDataset = null;
|
private Dataset currentDataset = null;
|
||||||
|
private Stage primaryStage = null;
|
||||||
|
|
||||||
public static void main( String[] args )
|
public static void main( String[] args )
|
||||||
{
|
{
|
||||||
@@ -27,14 +37,12 @@ public class App extends Application
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) {
|
public void start(Stage primaryStage) {
|
||||||
BorderPane root = new BorderPane(); //root panel
|
this.primaryStage = primaryStage;
|
||||||
Scene scene = new Scene(root,400,400);
|
try {
|
||||||
//create the menu
|
replaceSceneContent("menu.fxml");//replace this to check your fxml file
|
||||||
MainMenuBar menuBar = new MainMenuBar();
|
} catch (Exception e) {
|
||||||
root.setTop(menuBar.getmenuBar());
|
e.printStackTrace();
|
||||||
//TODO add the getting started page here.
|
}
|
||||||
|
|
||||||
primaryStage.setScene(scene);
|
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
//testing out dataset
|
//testing out dataset
|
||||||
try {
|
try {
|
||||||
@@ -62,6 +70,30 @@ public class App extends Application
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace Scene Content with fxml file code from oracle.
|
||||||
|
* @param fxml
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private Initializable replaceSceneContent(String fxml) throws Exception {
|
||||||
|
FXMLLoader loader = new FXMLLoader();
|
||||||
|
InputStream in = getClass().getClassLoader().getResourceAsStream(fxml);
|
||||||
|
InputStream menuIn = getClass().getClassLoader().getResourceAsStream("menu.fxml");
|
||||||
|
VBox page;
|
||||||
|
try {
|
||||||
|
page = (VBox) loader.load(menuIn);
|
||||||
|
Parent content = loader.load(getClass().getClassLoader().getResource(fxml));
|
||||||
|
page.getChildren().add(content);
|
||||||
|
} finally {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
Scene scene = new Scene(page, 800, 600);
|
||||||
|
primaryStage.setScene(scene);
|
||||||
|
primaryStage.sizeToScene();
|
||||||
|
return (Initializable) loader.getController();
|
||||||
|
}
|
||||||
|
|
||||||
public Dataset getCurrentDataset(){
|
public Dataset getCurrentDataset(){
|
||||||
return currentDataset;
|
return currentDataset;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
package seng202.group9.GUI;
|
|
||||||
|
|
||||||
import javafx.fxml.FXMLLoader;
|
|
||||||
import javafx.scene.Parent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Main Menu Bar for the program
|
|
||||||
* @author YaFedImYaEatIm
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class MainMenuBar{
|
|
||||||
|
|
||||||
final private String menuFXML = "menu.fxml";
|
|
||||||
|
|
||||||
public Parent getmenuBar(){
|
|
||||||
try{
|
|
||||||
Parent menuPane = FXMLLoader.load(getClass().getClassLoader().getResource(menuFXML));
|
|
||||||
return menuPane;
|
|
||||||
}catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -5,10 +5,13 @@ import java.util.ResourceBundle;
|
|||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
|
import javafx.application.Application;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
|
|
||||||
public class MenuController implements Initializable{
|
public class MenuController implements Initializable{
|
||||||
|
|
||||||
|
Application parent;
|
||||||
|
|
||||||
public void importAirports(){
|
public void importAirports(){
|
||||||
JOptionPane.showMessageDialog(null, "This is not Implemented yet");
|
JOptionPane.showMessageDialog(null, "This is not Implemented yet");
|
||||||
}
|
}
|
||||||
@@ -29,5 +32,9 @@ public class MenuController implements Initializable{
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setApp(Application parent){
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user