Converting FX application from Java into SARL

This commit is contained in:
ngaud 2017-05-02 16:43:01 +02:00
parent 01b4d82989
commit 6b02ee3c85
2 changed files with 39 additions and 41 deletions

View File

@ -1,41 +0,0 @@
package io.sarl.demos.fireworks;
import java.net.URL;
import io.sarl.demos.fireworks.gui.FXMLViewerController;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.fxml.JavaFXBuilderFactory;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class FireworksFXApplication extends Application {
private FXMLLoader loader;
@Override
public void start(Stage stage) throws Exception {
URL location = getClass().getResource("FireworksFXApplication.fxml");
loader = new FXMLLoader();
loader.setLocation(location);
loader.setBuilderFactory(new JavaFXBuilderFactory());
Parent root = (Parent) loader.load(location.openStream());
Scene scene = new Scene(root);
stage.setTitle("Firewoks sarl animation");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
@Override
public void stop() throws Exception {
// TODO Auto-generated method stub
super.stop();
((FXMLViewerController) loader.getController()).cleanExit();
}
}

View File

@ -0,0 +1,39 @@
package io.sarl.demos.fireworks
import io.sarl.demos.fireworks.gui.FXMLViewerController
import java.net.URL
import javafx.application.Application
import javafx.fxml.FXMLLoader
import javafx.fxml.JavaFXBuilderFactory
import javafx.scene.Parent
import javafx.scene.Scene
import javafx.stage.Stage
class FireworksFXApplication extends Application {
private var loader : FXMLLoader
@Override
public def start(stage: Stage) throws Exception {
var location : URL = getClass().getResource("FireworksFXApplication.fxml");
loader = new FXMLLoader();
loader.setLocation(location);
loader.setBuilderFactory(new JavaFXBuilderFactory());
var root : Parent = loader.load(location.openStream()) as Parent;
var scene : Scene = new Scene(root);
stage.setTitle("Firewoks sarl animation");
stage.setScene(scene);
stage.show();
}
public static def main(args: String[]) {
launch(args);
}
@Override
public def stop() throws Exception {
super.stop();
(loader.getController() as FXMLViewerController).cleanExit();
}
}