changeset 2:611b5be7f58c

add JavaFx main class
author one
date Sat, 26 Jan 2013 18:30:34 +0900
parents b997f2ce1a04
children 4930f8daf49d
files src/alice/test/topology/aquarium/fx/Aquarium.java
diffstat 1 files changed, 62 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/alice/test/topology/aquarium/fx/Aquarium.java	Sat Jan 26 18:30:34 2013 +0900
@@ -0,0 +1,62 @@
+package alice.test.topology.aquarium.fx;
+
+import java.io.IOException;
+
+import example.AddObject;
+import example.SetTranslation;
+
+import javafx.application.Application;
+import javafx.collections.ObservableList;
+import javafx.event.EventHandler;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Node;
+import javafx.scene.Scene;
+import javafx.scene.image.Image;
+import javafx.scene.image.ImageView;
+import javafx.scene.layout.AnchorPane;
+import javafx.stage.Stage;
+import javafx.stage.WindowEvent;
+
+public class Aquarium extends Application {
+
+	private ObservableList<Node> list;
+	
+	@Override
+	public void start(Stage primaryStage) throws IOException {
+		FXMLLoader loader = new FXMLLoader();
+		AnchorPane root = loader.load(getClass().getResource("aquarium.fxml"));
+		// AquariumController cont = (AquariumController) loader.getController(); get Controller instance
+		System.out.println(root.getChildren().get(1).getId());
+		ImageView iv = (ImageView) root.getChildren().get(3);
+		Image img = new Image("fish.jpg");
+		iv.setImage(img);
+		list = root.getChildren();
+		System.out.println(list.toString());
+		new SetTranslation(iv, "image1");
+		Scene scene = new Scene(root);
+        
+        primaryStage.setScene(scene);
+        primaryStage.setResizable(false);
+        primaryStage.show();
+        primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>(){
+        	public void handle(WindowEvent we) {
+            	System.exit(0);
+            }
+        });
+        new AddObject(this);
+		
+	}
+
+	public static void main(String[] args) {
+		launch(args);
+	}
+	
+	public void run(){
+		launch();
+		
+	}
+	
+	public ObservableList<Node> getList(){
+		return list;
+	}
+}