Procházet zdrojové kódy

Fixed Resource Loading for FXML File

Jan Enders před 8 roky
rodič
revize
ce9de0f01f

+ 1 - 1
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/App.java

@@ -11,7 +11,7 @@ import org.graphstream.graph.*;
 public class App {
 
 	public static void main(String[] args) {
-		
+
 		GraphMLImporter importer = new GraphMLImporter();
 		try {
 			Graph g = importer.readGraph("src/main/resources/TestGraphML.txt");

+ 1 - 1
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/GraphMLExporter.java

@@ -9,7 +9,7 @@ import java.io.IOException;
 import org.graphstream.*;
 
 public class GraphMLExporter {
-	public void writeGraph (Graph g, String fileName){
+	public void writeGraph(Graph g, String fileName) {
 		FileSinkGraphML writer = new FileSinkGraphML();
 		try {
 			writer.writeAll(g, new FileOutputStream(fileName));

+ 1 - 1
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/GraphMLImporter.java

@@ -10,7 +10,7 @@ import org.graphstream.stream.file.*;
 
 public class GraphMLImporter {
 
-	public Graph readGraph(String fileName) throws IOException{
+	public Graph readGraph(String fileName) throws IOException {
 		Graph g = new DefaultGraph("g");
 		FileSource fs = new FileSourceGraphML();
 		fs.addSink(g);

+ 26 - 28
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/MainApp.java

@@ -15,42 +15,40 @@ import javafx.scene.layout.VBox;
 import javafx.stage.Stage;
 
 public class MainApp extends Application {
-	
+
 	private Stage primaryStage;
-	private VBox rootLayout; 
+	private VBox rootLayout;
 
 	@Override
 	public void start(Stage primaryStage) {
 		this.primaryStage = primaryStage;
-		
-		
 
 		initRootLayout();
-		
+
+	}
+
+	public void initRootLayout() {
+		try {
+			// Load root layout from fxml file.
+			FXMLLoader loader = new FXMLLoader();
+			loader.setLocation(MainApp.class.getResource("/MainWindow.fxml"));
+			rootLayout = (VBox) loader.load();
+
+			// Show the scene containing the root layout.
+			Scene scene = new Scene(rootLayout);
+
+			AnchorPane anchor = (AnchorPane) rootLayout.getChildren().get(1);
+			Pane pane = (Pane) anchor.getChildren().get(1);
+			SwingNode swingNode = (SwingNode) pane.getChildren().get(0);
+
+			swingNode.setContent(new JButton("BLAAAAAA"));
+
+			primaryStage.setScene(scene);
+			primaryStage.show();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
 	}
-	
-	 public void initRootLayout() {
-	        try {
-	            // Load root layout from fxml file.
-	            FXMLLoader loader = new FXMLLoader();
-	            loader.setLocation(MainApp.class.getResource("view/MainWindow.fxml"));
-	            rootLayout = (VBox) loader.load();
-
-	            // Show the scene containing the root layout.
-	            Scene scene = new Scene(rootLayout);
-	            
-	            AnchorPane anchor = (AnchorPane) rootLayout.getChildren().get(1);
-	            Pane pane = (Pane) anchor.getChildren().get(1);
-	            SwingNode swingNode = (SwingNode) pane.getChildren().get(0);
-	            
-	            swingNode.setContent(new JButton ("BLAAAAAA"));
-	            
-	            primaryStage.setScene(scene);
-	            primaryStage.show();
-	        } catch (IOException e) {
-	            e.printStackTrace();
-	        }
-	    }
 
 	public static void main(String[] args) {
 		launch(args);

+ 0 - 0
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/view/MainWindow.fxml → scopviz/src/main/resources/MainWindow.fxml