Added Sample Loading for the GUI

main
YaFedImYaEatIm 9 years ago
parent 5c71a95e63
commit d7ddf99842

Binary file not shown.

@ -1,12 +1,21 @@
package seng202.group9.Controller;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
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.control.Menu;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import seng202.group9.GUI.MainMenuBar;
import seng202.group9.GUI.MenuController;
/**
* 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 Dataset currentDataset = null;
private Stage primaryStage = null;
public static void main( String[] args )
{
@ -27,14 +37,12 @@ public class App extends Application
*/
@Override
public void start(Stage primaryStage) {
BorderPane root = new BorderPane(); //root panel
Scene scene = new Scene(root,400,400);
//create the menu
MainMenuBar menuBar = new MainMenuBar();
root.setTop(menuBar.getmenuBar());
//TODO add the getting started page here.
primaryStage.setScene(scene);
this.primaryStage = primaryStage;
try {
replaceSceneContent("menu.fxml");//replace this to check your fxml file
} catch (Exception e) {
e.printStackTrace();
}
primaryStage.show();
//testing out dataset
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(){
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 javafx.application.Application;
import javafx.fxml.Initializable;
public class MenuController implements Initializable{
Application parent;
public void importAirports(){
JOptionPane.showMessageDialog(null, "This is not Implemented yet");
}
@ -29,5 +32,9 @@ public class MenuController implements Initializable{
// TODO Auto-generated method stub
}
public void setApp(Application parent){
this.parent = parent;
}
}

Loading…
Cancel
Save