view src/alice/test/topology/aquarium/fx/Aquarium.java @ 4:50d77513d52e

Platform runLater must use for handling instance from other thread (Not on FX application thread )
author e095732
date Mon, 28 Jan 2013 00:22:17 +0900
parents 4930f8daf49d
children ae0a39622a58
line wrap: on
line source

package alice.test.topology.aquarium.fx;

import java.io.IOException;


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;
	public AnchorPane root;
	
	@Override
	public void start(Stage primaryStage) throws IOException {
		root = FXMLLoader.load(getClass().getResource("aquarium.fxml"));
		// AquariumController cont = (AquariumController) loader.getController(); get Controller instance
		ImageView iv = (ImageView) root.getChildren().get(3);
		Image img = new Image("fish.jpg");
		iv.setImage(img);
		list = root.getChildren();
		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;
	}
}