Mercurial > hg > Members > tatsuki > Alice
changeset 381:6adfb60766f7 multicast
add window close event
author | sugi |
---|---|
date | Tue, 10 Jun 2014 13:41:11 +0900 |
parents | 29e75b92c358 |
children | 75411d4dc9f9 |
files | src/main/java/alice/test/topology/aquarium/fx/Aquarium.java src/main/java/alice/test/topology/aquarium/fx/CheckMyName.java |
diffstat | 2 files changed, 27 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/alice/test/topology/aquarium/fx/Aquarium.java Mon Jun 09 21:55:03 2014 +0900 +++ b/src/main/java/alice/test/topology/aquarium/fx/Aquarium.java Tue Jun 10 13:41:11 2014 +0900 @@ -16,6 +16,7 @@ import javafx.scene.transform.Rotate; import javafx.scene.transform.Translate; import javafx.stage.Stage; +import javafx.stage.WindowEvent; public class Aquarium extends Application { @@ -26,15 +27,36 @@ String myName = getParameters().getRaw().get(0); primaryStage.setTitle("Aquarium "+ myName); // name primaryStage.setResizable(false); - + primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>(){ + @Override + public void handle(WindowEvent event) { + System.exit(0); + } + }); + Scene scene = new Scene(createContent()); scene.setOnKeyPressed(new EventHandler<KeyEvent>() { public void handle(KeyEvent t) { - System.out.println(t.getCode()); - ods.put(myName+"FishPosition", new FishInfo(1,0,0)); + System.out.println(t.getCode()); + switch (t.getCode()) { + case RIGHT: + ods.update(myName+"FishPosition", new FishInfo(0.1,0,0)); + break; + case LEFT: + ods.update(myName+"FishPosition", new FishInfo(-0.1,0,0)); + break; + case UP: + ods.update(myName+"FishPosition", new FishInfo(0,-0.1,0)); + break; + case DOWN: + ods.update(myName+"FishPosition", new FishInfo(0,0.1,0)); + break; + default: // do nothing + break; + } } }); - + primaryStage.setScene(scene); primaryStage.show(); }
--- a/src/main/java/alice/test/topology/aquarium/fx/CheckMyName.java Mon Jun 09 21:55:03 2014 +0900 +++ b/src/main/java/alice/test/topology/aquarium/fx/CheckMyName.java Tue Jun 10 13:41:11 2014 +0900 @@ -27,7 +27,7 @@ FishInfo fishInfo = new FishInfo(0,0,0); fishInfo.setName(name); - fishInfo.setSize(2); + ods.put("fishData", fishInfo); new CreateObject();